cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

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

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

Administrator
Administrator

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
Community Manager
Power Automate | Power Virtual Agents
Super User Program Manager
Power Platform Communities

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
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (82,088)