Skip to main content

Notifications

Power Automate Trigger Conditions made EASY

Trigger Conditions in Power Automate were a great addition released in mid-2019. They are designed to stop your Flow (Automation) from running if the conditions are not met. Prior to this being released, you would need your automation to run and then you handled the condition whilst in flight. In the days where we had a pot of Flow runs, we would have automations running and spending our quota without actually delivering any value. Trigger conditions protect us from that.

 

Within this blog we'll look at how we can quickly and easily create our trigger conditions so that we know they are working. I can speak from experience that there's nothing more frustrating than trying to figure out the condition, and testing it by running your Flow and then not knowing truly whether it is correct or not.

How trigger conditions work

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.

 

As an example, I have a SharePoint list with a field called RunAutomation as a Yes/No field. I only want the automation to run if the field is set to YES. Therefore I need to use an expression to test for that, and for this comparison I need to use the function "equals":

 

 

 

@equals(triggerBody()?['RunAutomation'],true)

 

 

 

Trigger done.PNG

If you're happy with writing expressions, then you can crack on and just write it straight into the trigger condition. But if you're not so confident or you want that piece of mind that it's going to work first, then we can keep it simple and use Power Automate to confirm our logic.

Keep it Silly Simple

When ever I am creating my trigger conditions, I always create the expression within my automation first of all. This will allow me to evaluate whether my condition is going to work, and that I'm getting the desired results. Normally this is the first thing I will do, however we can do this later if we need to. I normally place an Initialize variable action directly beneath the trigger and then use that to write my expression.

Trigger Confirmation.PNG

When I create my variable, it will need to be of a type Boolean so that I can see whether it is going to return true or false. I effectively test my condition both ways to ensure that my expression is yielding the result I expect, therefore in this scenario I will trigger my automation from the SharePoint list, first of all selecting the RunAutomation as Yes, and then setting the RunAutomation to No.

 

In this example, I am testing the expression:

 

 

 

equals(triggerBody()?['RunAutomation'],true)

 

 

 

True Run.PNG

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 be:

 

 

 

@equals(triggerBody()?['RunAutomation'],true)

 

 

 


With this condition now in place, the automation will only run when it equates to true, i.e. only when RunAutomation is set to yes. Once I've set the trigger condition, I can then remove the test variable.

Finally

We have looked at what a trigger condition is, the ability to evaluate a value from the trigger which will determine whether the automation will run or not. This is a much more efficient way of doing this rather than doing the check once the automation has started.

 

The trigger condition takes the format of an expression, and must evaluate to either true or false. If it evaluates to true then the automation will run, otherwise it will ignore the trigger event.

 

The easiest way of being able to test this is by creating a variable as a Boolean within the automation, usually directly below the trigger which will allow you to write your expression and then test it. Ensure that you run the automation to test both positive and negative paths to ensure that your expression is evaluating to the correct result each time. Once that's done, you can past it into the trigger condition and then add the escape character @.

 

I hope you found this blog useful, and as always, feedback is very much welcome.

Comments

*This post is locked for comments

  • CU15081955-0 Profile Picture CU15081955-0
    Posted 26 Jun 2024 at 14:04:21
    Power Automate Trigger Conditions made EASY

    Hi, I'm new to power automate, and I'm reading the suggested trigger conditions, but I'm still not following which one would best suit my scenario. 

     

    I have a SPL form and flow setup, that when a SharePoint list item's "Status" is modified and changed to "Approved", it sends out an approval email to the creator/individual who submitted the item. Our flow is working great, but for some reason, the very first entry to our SPL, keeps receiving the approval email (even though the status has changed to approved) when others save their form and go back to make changes, or if the owners of the list go to make changes to other items. It doesn't send if new items are added, and I update the items to approved. It seems it only resends, when something in the background is "edited", and it only happens to this one user (which is the very first entry). The others entries aren't impacted by this. 

     

    I tried applying this trigger condition: @equals(triggerBody()?['Status'],'Approved'), but it stopped my flow from sending any approval emails completely. 

     

    Your help is very much appreciated! 

     

    Thank you

  • chantho Profile Picture chantho
    Posted 18 Nov 2022 at 00:34:10
    Power Automate Trigger Conditions made EASY

    It depends on the resulted data structure. If the data format is nested in body, fields or nested only inside fields the below format may help.

    @equals(triggerOutputs()?['body/fields/Status'],'Afvis')

    @equals(triggerOutputs()?['fields/Status'],'Afvis')

  • JulianaD Profile Picture JulianaD 25
    Posted 26 Jan 2022 at 02:21:25
    Power Automate Trigger Conditions made EASY

    The syntax you use will vary, to match what is shown in ARRAY, and whether it is a TEXT or CHOICE column... 

     

    See this: How to write Trigger Conditions for a specific tex... - Power Platform Community (microsoft.com)

     

    Cheers,

    Juliana Donkersgoed

    JulianaD_0-1647020963097.png

     

    JulianaD_0-1643162455488.png

    JulianaD_1-1643163038593.png

     

  • asamr Profile Picture asamr 54
    Posted 11 Oct 2021 at 05:51:33
    Power Automate Trigger Conditions made EASY

    @Vinniz Hey,

     

    You get a solution in this video for avoiding infinite loops.

     

    https://youtu.be/oKN4_5o2NUA

  • Vinniz Profile Picture Vinniz
    Posted 09 Oct 2021 at 13:53:58
    Power Automate Trigger Conditions made EASY

    Hello

     

    In my case I learned about infinite loop when I needed to update a column (let's call it copy-column1) with the value of a calculated column (let's call it column1) to be able to display the total sum in a list. 

     

    So what I did is that I simply have an "when an item is created or modified" flow and update the value of the copy-column1. But of course the flows triggers over and over.

    I did try  the condition like the one proposed and have the flow run only when the value in copy-column1 is not equal to column1, in vain...

     

    I tried it like that in the Trigger Conditions:

    @equals(triggerBody()?['column1'],triggerBody()?['copy-column1']).

    No success: the flow runs over and over.

     

    Is there a particular watchout for numbers, or when using calculating columns in the Trigger Conditions?

    I have a feeling that it is a syntax issue.

     

    Thanks for your support!

     

  • Craig_Humphrey Profile Picture Craig_Humphrey 166
    Posted 18 Aug 2021 at 21:05:50
    Power Automate Trigger Conditions made EASY

    @ninjaryder1st I suspect HasApplicantApplied is a string, so it may be "True" rather than true.

     

    Best thing to do is temporarily add a new initialize variable of type string and set the value to HasApplicantApplied (choose it from the parameters you're passing in, or wherever you're getting it from). This will test two things:

    1. What's the actual syntax for referring to HasApplicantApplied, as it's not always triggerbody.

    2. What the data type is for HasApplicantApplied, as it could be a string or a number.

     

    Good luck!

  • ninjaryder1st Profile Picture ninjaryder1st 230
    Posted 18 Aug 2021 at 14:18:33
    Power Automate Trigger Conditions made EASY

    This is a great tool and article explaining how to limit runs, and API used.

    It feels like you left out 1 important part....... the script/command you actually placed into the initialize variable "value" field for the function (x) or Fx expression.   

     

    The screen shot shows us Fx equals(...) but I'm not sure what to place there for testing my expression using Initialize Variable.  

     

    ninjaryder1st_0-1629296064242.png

     

      I'd like to test/use the trigger equation for a boolean condition (true/false) for an expression like this:

     

    @equals(triggerbody()?['HasApplicantApplied'],true)

     

    but it doesn't respond in testing the flow with this placed into the trigger condition (when an item is created or modified) area for the flow.     Can you share what the fx expression was?

  • asamr Profile Picture asamr 54
    Posted 19 Jul 2021 at 23:29:54
    Power Automate Trigger Conditions made EASY

    @C3PO-  Yes check this out. 🙂

     

    https://powerusers.microsoft.com/t5/Building-Flows/Sharepoint-Specific-column-change-to-a-specific-value/m-p/1066319#M136995 

  • C3PO- Profile Picture C3PO-
    Posted 19 Jul 2021 at 21:58:46
    Power Automate Trigger Conditions made EASY

    @asamr were you able to isolate on a choice column and a specific choice? I've been trying to get this to work this afternoon and it just plain doesn't trigger for me. 

     

    TIA for any help you can give if you figured it out!

  • asd2525 Profile Picture asd2525 66
    Posted 09 Jul 2021 at 18:14:12
    Power Automate Trigger Conditions made EASY

    Deleted Comment