Flow Patterns: Trigger Conditions
Goal
Run a Microsoft Flow only when a particular condition is met.
Solution
I previously wrote about a conditional start for flows using conditions and the Terminate Flow
action.
Here’s an alternative approach that leverages Trigger Conditions. This approach hides the flow’s starting condition better, which may be pros or cons depending on your situation.
Let’s consider a sample flow scenario “Send a customized email when a new file is added”. This flow will send an email for all new items created in a document library, both documents and folders:
If we don’t want to start the flow for folders, we can specify a trigger condition in the “When a file is created (properties only)” trigger action settings:
I’m using the triggerBody()
expression to get details of the trigger. The condition will evaluate to False
for folders, so the flow will start only for documents:
This way you can specify multiple conditions for a flow.
How to view skipped runs
Using a trigger condition you won’t see skipped runs in a flow’s dashboard:
To view skipped runs you need to select All runs
link in a top right corner of a “Runs” window. In the opened window, select “Checks (no new data)” to view flow runs that were skipped due to a trigger condition.