cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate III
Advocate III

How to edit definition.json to add condition to the trigger?

Like many people I use Flow primarily with SharePoint and constantly struggle with the fact that the Update command triggers another flow and creates an infinite loop. I personally believe that MSFT must provide a property on the trigger called "Run Once" that users can click. Until that happens the adoption of FLOW will be severely hampered and people will continue to use SharePoint Designer, which does allow this functionality. Remember Microsoft, you are selling this to PRO USERS, not DEVELOPERS.

 

Here is my workaround for this:

  • Create a field in your Sharepoint list called "RunFlow" and set it to "Yes".
  • Include a Condition at the top of your Flow that looks at this value and Terminates if it is "No".
  • Then in your Update command set it to "No".
  • If users want to run the Flow again, they can set this field to "Yes" in their edit. Even better, if you use PowerApps for all edits, you can see this field to "Yes" when you Submit.

However, this still creates TWO Flow runs, the intial one and the second one that see that "RunFlow" is "No" and terminates and another flow everytime someone edits a list item without changing the "RunFlow" to "Yes".  This is not desirable since it racks up the Flow count (maybe this is MSFT'S evil purpose? LOL!) Also it's confusing to see all these Cancelleds in your stats.

 

In June there was a discussion in the Flow Ideas (look at the last two comments) around this issue which claimed that it is possible to add a condition in the definition.json to prevent the second Flow run. I edit the Flow definitions all the time when I upload Flows to customer tenants because I don't like changing all the SharePoint list definitions manually, so I'm not concerned with editing this file. (I just find and replace all the SharePoint list GUIDs in the definition.json, which is less prone to error).

 

Anyway, can anyone tell me HOW to add a condition to the definition,json trigger? Here's my Pseudo Code for the condition;

 

IF

@equals(triggerBody()?['RunFlow']?['Value'], 'No')

DON'T RUN THE FLOW

 

Here's where I think the condition would be added to the definition.json. Any ideas greatly appreciated!

 

jsondefinitionflow.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to edit definition.json to add condition to the trigger?

I fully agree, this is an issue we have been complaining since day 1. Perhaps can you take a look at my solution for associating flows to some content types. 

 https://sergeluca.wordpress.com/2018/04/11/trigger-your-flow-only-when-a-document-is-created-from-a-...

 

But be very careful, even though manually changing JSON code can work in logic apps, it might not be supported in Flow because the Flow Designer might change your value

 

Another pattern is to have a scheduled flow that checks the changes (ever 5 minutes) instead of beeing triggered when there is a modification. 

 

View solution in original post

3 REPLIES 3
Highlighted

Re: How to edit definition.json to add condition to the trigger?

I fully agree, this is an issue we have been complaining since day 1. Perhaps can you take a look at my solution for associating flows to some content types. 

 https://sergeluca.wordpress.com/2018/04/11/trigger-your-flow-only-when-a-document-is-created-from-a-...

 

But be very careful, even though manually changing JSON code can work in logic apps, it might not be supported in Flow because the Flow Designer might change your value

 

Another pattern is to have a scheduled flow that checks the changes (ever 5 minutes) instead of beeing triggered when there is a modification. 

 

View solution in original post

Highlighted
Administrator
Administrator

Re: How to edit definition.json to add condition to the trigger?

Hello, @kbirstein1!

Thank you for posting on the Flow Community Forum! Have you had an opportunity to apply @sergeluca‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!


Thank you for being an active member of the Flow Community!

-Gabriel
Flow Community Manager

-Gabriel
Microsoft Power Automate Community Manager
Are YOU a member of your local Power Automate User Group?
Fill out This Form to claim your Community User Group Member Badge!
Highlighted
Advocate III
Advocate III

Re: How to edit definition.json to add condition to the trigger?

Thanks sergeluca,

 

Sorry it took me a few days to get back to you but I've been overwhelmed.

 

I added the condition to definitions.json successfully (see screenshot) and it seems to be working. Thanks so much!

 

Kathryn

 

DefinitionCondition.png

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (9,649)