cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kbirstein1
Level: Powered On

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
Super User
Super User

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
Super User
Super User

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

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 Flow Community Manager
kbirstein1
Level: Powered On

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 76 members 4,025 guests
Please welcome our newest community members: