“I’d like to trigger my Power Automate flow only when a specific file(s) are modified, not for all the files in the library!”
When you build a flow in Power Automate, it’s connected to the whole library. It doesn’t care what file users add or modify, it’ll process all the files in the same way. But sometimes you don’t want to process every file. There could be a change notification only for a single file in the library. Approval process that’s started only for a specific file type. Or a flow based on the file location in a folder structure. In all these situations it’s necessary to somehow recognise the file and process it or not.
Don’t use a ‘Condition’
While the first idea can be to use a ‘Condition’ in the flow, it’s not the right approach. To evaluate a condition the flow would have to trigger. Each trigger will cost you API calls and create an entry in the flow run history, leading to bit of a mess. That’s why you should go one step back, to the trigger.
Use a ‘Trigger Condition’ instead
If you go in the trigger settings, you’ll see a section called ‘Trigger Conditions’.
The trigger conditions setting allows you to add a condition directly in the trigger.
The flow doesn’t have to trigger to evaluate this condition, it’ll check it before that happens. If the condition returns ‘true’, the flow will run. If it returns ‘false’ the flow won’t start.
Therefore, if your goal is to run a flow only for a specific file, you should use a trigger condition. You can run the flow only for a file with an exact name:
It’s possible to run it for files that contain a specific string in the file name:
It can trigger for a specific file type:
Or run on files in a specific folder:
Don’t worry if you don’t know how to create such condition, you can use a workaround with the ‘Filter array’ action to create the right one for your needs.
Enter the condition as the ‘Trigger Condition’ in the trigger action and let your flow run only when it’s needed.
If you want to trigger your Power Automate flow only on a specific file, you should identify the file right away. That means in the trigger. Instead of running the flow for all the files and deciding in the flow what to do, you can use a trigger condition and run the flow only when necessary.
4 thoughts on “Trigger Power Automate flow only on specific file in a library”
Hi Tom! Great post, this low-code approach is immensely helpful! Would it be possible to use low-code in order to enable the flow to identify specific destination folders based on date?
i.e. A file that has the date March_2022 in its title to be copied in the relevant destination folder, March 2022 and so on, without having to create multiple flows for each year/month.
you can do that, just split the file name (https://tomriha.com/how-to-split-file-name-for-further-processing-in-power-automate/) and then use the parts of the name to build the destination folder.
I’m keeping my monthly file in a Sharepoint folder. Every month, I’m adding a File with a file name format of ReviewBSR . Now I want to do conditional trigger that will only trigger the flow whenever I’m creating new files in this folder with a file name that starts with ReviewBSR
you can combine the action settings (it has a possibility to select which folder it should check) with a trigger condition @startsWith(…) (instead @endsWith from the article).