How to put a trigger condition to your trigger in Power Automate?

Problem Definition:

Usually we have Triggers such as “Item Added or Modified” for a list or library. This is a first action in your workflow. Now assume that there is “WaveStatus” field in your list. You want a condition in your Trigger to activate only when Status is equals to “Completed”.

(Assuming your WaveStatus field has “New”, “InProgress”, “Hold” and “Completed”)

The issue with this approach is your workflow will trigger for all conditions even if some made a change to “Hold” from some other values. Even worst the trigger will fire for any field change in your list item.

Solution:

TTP: Use a “Compose” Action and type a function triggerBody(). Run the once without any actions. Note the output of compose keep copy to understand what comes to your flow as an input. This will be in JSON, I suggest learning a high level anatomy of JSON.

  1. Click on the ‘…’ on your trigger and select ‘Settings’
  1. In the Settings dialog, you will be adding the Trigger Condition. Please make a note your expression must have ‘@’ character.

e.g. @equals( triggerBody()?[‘WaveStatus’]?[‘Value’],’Completed’)

Conclusion

This will allow your work flow to trigger only when item is modified with the value WaveStatus=’Completed’. This will prevent unnecessary workflow run.

Happy Coding!

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in Power Automate. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s