How can you create a Power Automate flow that triggers only when a specific metadata field within a SharePoint document library is changed?
To create a Power Automate flow that triggers only when a specific metadata field within a SharePoint document library is changed, you need to use a trigger based on item modification and then add a condition to check if the specific metadata field has been altered. Start with the 'When a file is created or modified' trigger for the specific SharePoint document library. This trigger fires whenever a file is added or modified, but you need to refine it to trigger only on changes to your specific metadata field. After the trigger, add a 'Get file metadata' or 'Get file properties' action, pointing to the file that triggered the flow. This action retrieves all the metadata for the file, including the value of the specific field you are monitoring. Then, use a 'Compose' action to store the *previousvalue of the metadata field. The key is to implement a mechanism to retain the previous value for comparison. One way to do this is using a SharePoint list dedicated to storing file metadata history, including the file ID and the tracked metadata field. Within the flow, query this list to retrieve the last recorded value for the specific file before the 'Get file metadata' action. If no entry exists, it's a new file. After the 'Get file metadata' action, add a 'Condition' action. In the condition, compare the *currentvalue of the metadata field (from the 'Get file metadata' action) with the *previousvalue (retrieved from the history list or the 'Compose' action for new files). If the values are different, the condition is true, and the flow proceeds with subsequent actions. If the values are the same, the flow does nothing (or can be terminated). Finally, if the condition is true, update the metadata history list with the new value of the metadata field. This ensures that the next time the flow runs, it has the correct previous value to compare against. This setup ensures the flow triggers only when the designated metadata field is modified, avoiding unnecessary executions for other file changes.