FLOW Trigger Conditions For SharePoint - Run FLOW When Needed

Problem

You have FLOW running on your SharePoint list or library. You have added a few conditions in your FLOW so that the actions/logic runs only in specific scenarios. But the flow will get triggered every time when the item is modified, which you don’t want to happen. This will unnecessarily consume FLOW runs, which might become a problem for small organizations with a large number of processes.

So, the problem here is how to trigger a FLOW only when it’s really needed.

Solution

Considering the example of the “When an item is created or modified” trigger, you use this trigger to run the FLOW when a new item is added in your list or when the item is modified by the end user. You want the FLOW to run only when the Status columns have the value “In Progress” or “Done”. FLOW should not run when the Status column value is anything other than these two values. How to achieve this?

Yes, it's achievable now.

With almost all SharePoint triggers the Power Automate team has come up with a new feature in recent months called "Trigger Conditions". It says - Specify one or more expressions which must be true for the trigger to fire. This uses the same expressions or query syntax that gets generated in any FLOW action; e.g. Condition action in FLOW.

Let’s see how to do it. Login to https://flow.microsoft.com/ >> Create a new FLOW or edit your existing FLOW which has a "When an item is created or modified" trigger. If it's a new FLOW, then add the below trigger:

FLOW

As shown below, Click on the Menu button >> Settings option.

Settings Option

There is a Trigger Conditions section in the settings as shown below >> Click on the +Add button to add your rule or condition. If this condition is satisfied then only FLOW triggers otherwise not.

Trigger Conditions

Let’s see some of the examples.

Single Condition

Run the FLOW only when the Task Status is Done. In my demonstration, Task Status is in the Choice column. So, I need to use the value parameter.

@equals(triggerBody()?['Task_x0020_Status']?['value'], 'Done')

Task Status

Two OR conditions

When you need to check two conditions with the OR clause then use the expression as shown below, this checks if Notify All is true or Published is true.

@or(
    equals(triggerBody()?['Notify_x0020_All'], true),
    equals(triggerBody()?['Published'], true)
)

Two or more AND conditions

When you need to check multiple conditions with an AND clause then just keep adding more conditions by clicking on the Add button. And add individual condition expressions in each of the text fields as shown below.

Split on

OR and AND Conditions together

When you need to check more than 2 conditions with Or and And clauses then you need to combine the above two scenarios, OR you can just create one expression and put it in one box as shown below. Make sure you do not put the @ prefix before and clause when it is a nested condition.

@or(
    equals(triggerBody()?['Notify_x0020_All'], true),
    and(
        equals(triggerBody()?['Published'], true),
        equals(triggerBody()?['PublishedNotificationSent'], false)
    ),
    equals(not(empty(triggerBody()?['Notify_x0020_Specific_x0020_Person'])), true)
)

Some more tips

  • How to check if the column is empty or has no value?
  • Use the empty() function.
  • How to check if the column is not empty or has some value?
  • Use not and empty functions together.
  • not(empty())

Summary

So, we can have control over the FLOW runs as depending upon your licensing you get a limited number of FLOW runs per user per month. Trigger conditions trim down FLOW runs and help trigger FLOW only when it’s really needed.

Hope this helps. Thanks for reading.


Similar Articles