Trigger Power Automate (Flow) based on condition in SharePoint Online

Trigger Power Automate (Flow) based on condition in SharePoint Online

No comments

 3,851 total views,  18 views today

In this tutorial, we will learn how to trigger a Power Automate (Microsoft Flow) conditionally (based on certain conditions) in SharePoint Online.

Key-Highlights: What you will learn from this tutorial?

  • Introduction – benefits of conditional trigger in Power Automate
  • Demo – how to trigger a Power Automate with the conditioning step by step?
  • How to configure the conditional trigger in Power Automate?
  • Various Expression in Power Automate Trigger condition
  • Various configuration in Power Automate (Flow) trigger
  • Verify the conditional triggering in Power Automate from SharePoint Online list – positive testing
  • Verify the conditional triggering in Power Automate from SharePoint Online list – negative testing

Introduction – benefits of conditional trigger in Power Automate

The trigger conditions in Power Automate (Microsoft Flow) were a great addition released in mid-2019. Prior to this being released, the flow (Power Automate) would run every time whenever any items were added or created based on the trigger action template you select (on item creation or modification) – then, inside the Power Automate (flow) we had to add if condition to control the execution of subsequent actions or flows down the line. This costs extra burden or licensing in terms of executing the number flow per tenant for a certain period. Now, after this release – the power automate will not get triggered until a certain condition is met true. So, before coming to the particular Power Automate we have the option to check the trigger condition. In the world of workflow automation, the other counter-part big-name “Nintex” has had this conditional trigger option to configure, in this perspective the Power Automate was lagged-in comparing to Nintex workflow.

Demo – how to trigger a Power Automate with the conditioning step by step?

As part of the demo, below is the employee list structure where one of the columns is “IsADUser” with the (Yes/No) type – in this demo, we will see if “IsADUser” is “Yes” then only the Power Automate should get triggered, otherwise not, now let’s begin with this step by step.

Trigger Power Automate conditionally - list structure
Trigger Power Automate conditionally – list structure

I have created a test Power Automate named “Conditional Flow Trigger Test”.

And below are the configuration of the Power Automate.

When an item is created or modified - Conditional Flow Trigger
When an item is created or modified – Conditional Flow Trigger

In the above Power Automate, I have selected the trigger template as “When an item is created or modified”, then creating a variable named “var_IsFlow_Triggered_Check” with boolean type whose default value is set to false, once the Power Automate gets executed successfully this boolean “var_IsFlow_Triggered_Check” variable will be set to “true”.

How to configure the conditional trigger in Power Automate?

Go to the first trigger template “When an item is created or modified”, click on the three dots, then click on the settings as shown below:

Power Automate conditional trigger settings
Power Automate conditional trigger settings

Once we click on the “Settings”, we will go to the “Settings for ‘When an item is created or modified'” screen as shown below:

Trigger Conditions - Specify one or more expressions which must be true for the trigger to fire
Trigger Conditions – Specify one or more expressions which must be true for the trigger to fire

By default, Split On will be in disabled mode, make it enable. Once we enable the split on we can see that @triggerBody()?[]’value’] is displayed in the array dropdown list.

Split On - Split On Enable split-on to start an instance of the workflow per item in the selected array. Each instance can also have a distinct tracking id
Split On Enable split-on to start an instance of the workflow per item in the selected array. Each instance can also have a distinct tracking id

Then go to the “Trigger Conditions” section located at the bottom of the screen.

Trigger Conditions to Specify one or more expressions which must be true for the trigger to fire
Trigger Conditions to Specify one or more expressions which must be true for the trigger to fire

Click on the “+ Add” button shown above.

Add the below trigger condition to the box.

@equals(triggerBody()?['IsADUser'],True)

 

Trigger Conditions - equal triggerBody
Trigger Conditions – equal triggerBody

Then click on the “Done” button.

Notes:

  • The above trigger condition is checking if “IsADUser” is equal to “Yes” for a certain item in the SharePoint list, then this will get triggered for that item.
  • In the above expression “True” shouldn’t be in lower case i.e. instead of “True” if we write “true” it won’t trigger, I have experienced this.
  • The general rule of thumb is – in order to trigger the PowerAutomate, the expression outcome must be a “True“.
  • In the above example, I have used the “When an item is created or modified” trigger action, however the conditional trigger configuration in all the trigger actions like  “When an item is created in SharePoint list” or “When an existing item is modified in SharePoint list”.
  • Apart from the “Split On” and “Trigger Conditions” configuration we can keep the rest of the configurations as is.
  • We can add multiple trigger conditions by clicking on the “+ Add button“.

Various Expression in Power Automate Trigger condition

Expression Result Type Valid Condition
@add(1, 0)

 

Integer No
@true

 

Boolean Yes
@equals(1, 1)

 

Boolean Yes
@json(triggerBody()) Object No

 

 

Various configuration in Power Automate (Flow) trigger

Though the “Split On” and “Trigger Conditions” are sufficient to run the conditional Power Automate (flow).

For our own knowledge, we should know about the rest of the configurations, so let’s know about those configurations.

Custom Tracking Id:

Set the tracking id for the run. For split-on, this tracking id is for the initiating request.

Custom Tracking ID configuration in Power Automate
Custom Tracking ID configuration in Power Automate

Secure Inputs (Preview)

Secure inputs of the operation.
Secure Inputs – Enable/Disable Toggle

Select Input Preview configuration in Power Automate (Microsoft Flow)
Select Input Preview configuration in Power Automate (Microsoft Flow)

Retry Policy

A retry policy applies to intermittent failures, characterized as HTTP status codes 408, 429, and 5xx, in addition to any connectivity exceptions. The default is an exponential interval policy set to retry 4 times. The retry policy can be selected as one of the below choices:

  • Default
  • None
  • Exponential Interval
  • Fixed Interval
Retry policy configuration in Microsoft Power Automate
Retry policy configuration in Microsoft Power Automate

Concurrency Control

Limit the number of concurrent runs of the flow, or leave it off to run as many as possible at the same time.
Concurrency control changes the way new runs are queued. It cannot be undone once enabled.

Limit – Enable/Disable Toggle

Concurrency Control configuration in Power Automate (Microsoft Flow)
Concurrency Control configuration in Power Automate (Microsoft Flow)

 

Verify the conditional triggering SharePoint Online list – Positive testing

Go to the “Employee” list and for an item change the “IsADUser” value to “Yes” from “No”.

Trigger Power Automate based on condition from SharePoint Online list
Trigger Power Automate based on the condition from SharePoint Online list

Now, power automate should be triggered.

Go to the “28-day run history” of the Power Automate log report, we can see that a few minutes ago, the Power Automate (Microsoft Flow) ran successfully.

 

28-day run history - Power Automate
28-day run history – Power Automate

Now, click on the “Oct 31, 8:06 AM (6 min ago)” link from the above report.

In the next screen, we can see the message – “Your flow ran successfully” with all green ticked which confirmed all the actions in the flow have been executed successfully.

Your flow ran successfully message from Power Automate log
Your flow ran successfully message from Power Automate log

By now we have tested the positive scenario that is when the “IsADUser” value is set to “Yes” in the SharePoint Online list for the configured site and list (Employee), the flow should get triggered, and we have seen this worked.

Verify the conditional triggering SharePoint Online list – negative testing

In this section, we will perform the negative testing that is we will set the “IsADUser” value to “No” again for the same item in the SharePoint list, and this time the flow should not get triggered as the trigger condition will fail.

Trigger flow conditionally from SharePoint Online list - negative testing
Trigger flow conditionally from SharePoint Online list – negative testing

Now, if we go to the “28-day run history” report, we can see that the flow didn’t get triggered as the condition was not met true (“IsADUser”=No).

 

Trigger flow conditionally from SharePoint Online list - negative testing Power Automate Log Report
Trigger flow conditionally from SharePoint Online list – negative testing Power Automate Log Report

Summary: What we had here?

Thus, in this article, we have learned about how to trigger a Power Automate (Microsoft Flow) conditionally that is based on certain value changes in the SharePoint Online list. We can summarize the learning as below:

  • Introduction – benefits of conditional trigger in Power Automate
  • Demo – how to trigger a Power Automate with the conditioning step by step?
  • How to configure the conditional trigger in Power Automate?
  • Various Expression in Power Automate Trigger condition
  • Various configuration in Power Automate (Flow) trigger
  • Verify the conditional triggering in Power Automate from SharePoint Online list – positive testing
  • Verify the conditional triggering in Power Automate from SharePoint Online list – negative testing

See Also

You may also like the below Power Automate tutorials:

Free download SharePoint Online & Office 365 Administration eBook(238 Pages)

Get the PDF eBook from here:


 
FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.