It is common to use the ‘When an item created or modified’ trigger when creating flows for SharePoint with Power Automate to perform some actions based on some conditions. Before the Trigger Conditions were released, we need to write a condition to perform the action after flow runs. As a result, we would have Flows running and spending our quota without delivering any value. Trigger conditions protect us from that.
Using trigger conditions, one can control the flow to execute or not. This also prevents generating unnecessary entries in Run History.
The first thing for us to understand is how the trigger conditions work. Effectively they work in the same way as an expression, whereby we provide it with a function name, some parameters, all done to determine an outcome of TRUE or FALSE.
For example, I need to generate some PDFs based on some values from the SharePoint list. And it should be generated only when all values which are required in PDF should be available then only this flow should be run to generate the PDF.
To achieve this, I have one field in the SharePoint list called “PDF Status” and it has values – “Not Ready”, “Ready to Generate”, “Generated”. When all the fields have proper values in SharePoint List (Field values may updated from another source like PowerApps, Power Automate, etc.) and the value for the “PDF Status” has changed to “Ready to Generate” then our flow will run.
Go to the trigger template “When an item created or modified”, click on the three dots, then click on the settings as shown below:
Once we click on the “Settings” we will go to the “Settings for ‘When an item created or modified’” screen as shown below:
I only want the automation to run if the field set to “Ready to Generate” Therefore, I will use the function “equals” to check its value.
If you are good with writing expressions, then you can just write it straight into the trigger condition. But if you are not so confident or you want to check whether it’s going to work first, then we can keep it simple and use Power Automate to confirm our logic.
Just add Initialize variable action directly beneath the trigger and then use it to write your expression like below:
Expression : equals(triggerOutputs()?[‘body/PDFStatus/Value’],’Ready to Generate’)
The Variable needs to be of a type Boolean so that we can see whether it is going to return true or false. I will trigger my flow from the SharePoint list, first I will set PDF Status as “Not Ready”, and then set it to “Ready to Generate”.
Once I am sure that the expression is working as I want, I can then take the expression and place it into the trigger condition. The one addition I need is to add the escape character at the start which is the @ symbol. Therefore, my trigger condition will look like below then click on Done.
Once I have set the trigger condition, I can then remove the test variable in the flow. It will only run when it equates to true.
Automating your business processes with Microsoft Power Automate is a great way to reduce operational costs and increase efficiency. To learn more about why you should be using this technology, contact us today!
I hope you found this blog useful.
Let’s discuss your project
Written by Priyanka Patel
Priyanka is Senior Software Developer at Evolvous Limited – specialists in Microsoft Technologies.