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

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
sergeluca
MVP

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. 

 

GabrielStJohn
Community Champion
Community Champion

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



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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,500)