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 “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 Status columns has value “In Progress” or “Done”. FLOW should not run when the Status columns 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 same expressions or queries syntax which 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 new FLOW or edit your existing FLOW which has "When an item is created or modified" trigger. If it's a new FLOW, then add the below trigger:
 
FLOW Trigger Conditions For SharePoint - Run FLOW When Needed
 
As shown below, Click on Menu button >> Settings option
 
FLOW Trigger Conditions For SharePoint - Run FLOW When Needed
 
There is a Trigger Conditions section in the settings as shown below >> Click on +Add button to add your rule or condition. If this condition satisfies then only FLOW triggers otherwise not.
 
FLOW Trigger Conditions For SharePoint - Run FLOW When Needed
 
Let’s see some of the examples:
 

Single Condition

 
Run the FLOW only when Task Status is Done. In my demonstration Task Status is in Choice column. So, I need to use value parameter.
  1. @equals(triggerBody()?['Task_x0020_Status']?['value'],'Done')  
FLOW Trigger Conditions For SharePoint - Run FLOW When Needed
 

Two OR conditions

 
When you need to check two conditions with OR clause then use the expression as shown below, this checks if Notify All is true or Published is true.
  1. @or(equals(triggerBody()?['Notify_x0020_All'],true),equals(triggerBody()?['Published'],true))  

Two or more AND conditions

 
When you need to check multiple conditions with AND clause then just keep adding more conditions by clicking on Add button. And add individual condition expression in each of the text fields as shown below
 
FLOW Trigger Conditions For SharePoint - Run FLOW When Needed
 

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 @ prefix before and clause when its nested condition.
  1. @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 column is empty or has no value?
 
Use empty() function.
 
How to check if column is not empty or has some value?
 
Use not and empty function together.
 
not(empty())
 

Summary

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