Microsoft Power Automate Flow Trigger Conditions & CDS Filter Expressions Explained!

By | June 4, 2020

Microsoft Power Automate Flows are the recommended path forward for extending business logic that traditionally was extended using Plugins and Workflows.

For code execution trigger we were only offered message as an option and in case of the update message a step forward to choose the fields that need to be updated for the plugin or workflow to be executed.

However if we wanted to get the code to execute/trigger based on a certain value, we had to check for that condition within the code or as a step in the workflow which means the workflow or the plugin code would always trigger.

Power Automate Flows has a very powerful feature that helps cover this limitation of plugins and workflows and thereby reduce unnecessary execution of the flows. Do note that while the direction from Microsoft is to move to Flows for biz logic extensions, unlike plugins or workflows where there were no limits to the count of workflow jobs available for execution, Flows depending on the plan that you have subscribed to are limited in number. This makes it all the more important to prevent unwanted flow executions.

Trigger Conditions for Trigger Steps

Let us have a look at how the trigger conditions can be specified. In the example below we have used the update trigger of the Common Data Service (Current) connector, you could apply trigger condition on any connector and trigger too. This is a part of the Power Automate platform framework.

Start with the Create/Update trigger as shown below

Microsoft Power Automate Flow Trigger Conditions

Once added, click on the settingMicrosoft Power Automate Flow Trigger Conditions

In the trigger conditions you could specify flow expressions that evaluate to true and false. As you can see in the screenshot, you could provide one or more expressions, if you add more than one expression, it is an AND between them, which means all expressions provided should evaluate to TRUE for the trigger to execute.

Let us have a look at this expression

@equals(triggerbody()?[‘prioritycode’],1)

This checks if the priority code of the record for which the action is triggered is set to 1. Since it is an optionset type of field we have used the integer value.

Alternatively, you could compare with the optionset labels using the second example shown above

@equals(triggerbody()?[‘_leadsourcecode_label’],’Advertisement’)

Instead of an AND if you would have liked an OR between the two conditions, you could rewrite this as

@or(@equals(triggerbody()?[‘prioritycode’],1),@equals(triggerbody()?[‘_leadsourcecode_label’],’Advertisement’))

Check for the various operators supported here

Filter Expression in Common Data Service (Current) Trigger

While trigger condition is a part of the Power Automate framework and is available for all connectors and their triggers, Microsoft has added an easy way to specify the trigger condition for the Common Data Service (Current) connector.

Microsoft Power Automate Flow Trigger Conditions

You now see Filter Expression as one of the options to be specified in the trigger properties.

This works similarly to the trigger condition but requires the filters to be specified in ODATA format that we CDS developers are used to.

Unless the filter expression evaluates to true, the trigger will not be fired and it will not account towards the flow execution limits set.

Conclusion

Make use of trigger conditions to design efficient flows and avoid unnecessary executions.

70% of global 2000 companies apply gamification to improve productivity and returns!

Gamifics365 – Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!

4 thoughts on “Microsoft Power Automate Flow Trigger Conditions & CDS Filter Expressions Explained!

  1. Katrina

    Are you sure there’s ONE trigger for all three actions (Create, Update, Delete)? It appears that there’s actually three separate triggers. Could you post what version of Automate you are using?

    I also don’t see a field for ‘Filtering Attributes’ – your screen looks completely different that what I have available.

    1. Inogic

      Hi,

      Yes there’s one trigger for all three actions (Create, Update, Delete).

      This trigger is available for the connector “Common Data Service (current environment)”

      The below Microsoft link gives the list of triggers for this connector
      https://docs.microsoft.com/en-us/connectors/commondataserviceforapps/#triggers

      To get the connector “Common Data Service (current environment)” you will have to navigate to power platform
      by logging in to “https://make.powerapps.com/” where in your environment you need to create a solution and from there
      you need to create a MsFlow.

      Hope this helps.

      Thanks!

  2. Roy P

    I have a custom lead attribute (xyz_stale, which is a boolean), and I have my trigger setup as below, but flow tells me there is a problem with the trigger and won’t run successfully.

    trigger condition: update
    entity: lead
    scope: org
    filter attribute: xyz_stale
    filter expression: xyz_stale eq 1

    1. Inogic

      Hi,

      The filter expression while using Boolean field should be as below:

      xyz_stale eq true

      The example in our blog shows the expression for an Optionset field.

      Hope this helps.

      Thanks!

Comments are closed.