cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
WillyD44
Level 8

How to stop infinite loop when workflow modifies list that workflow is set to run on

I have a SharePoint library, we'll call it Library "Test".   I have a custom approval (NOT using the approval actions in FLOW) process I built using standard SharePoint and Office 365 Connectors.  The FLOW has some delays in it as well.  

 

The FLOW triggers on "When a file is created or modified (Properties only).  The problem is that the workflow may run for a few days, waiting for a status change.  If Joe User comes along and makes a change to the file or to any of it's properties...that kicks off the FLOW again.  I don't want that (in SharePoint Designer, you could only have one instance of one workflow running on an item or on a document and it's properties at a time.  If somebody modified the list or library item while a SPD workflow another instance of the workflow running - quick note for Microsoft...I've been noticing that FLOW offers some GREAT functionality, but it misses huge too often when it comes to SharePoint which I would presume is the primary platform for FLOWs.  If that presumption is correct, I'm hoping to see the FLOW team do some focused analysis on what is left to cover 

to make sure FLOW is solid when it comes to SharePoint and does everything that Designer did - I digress, but only because I have a certain level of passion around workflows) to happen.  This ends up creating an infinite loop, because actions inside the workflow that write back to the underlying library (changing column values) start up a new instance of the workflow.

 

Is there a workaround to stop this infinite loop? 

 

I don't think there is...in the event I'm correct in my understanding...it would be great (super useful) to have the choice to be able to configure a global setting for the workflow...something like this:

 

Check this box to only allow one instance of this workflow to run at a time (if this workflow is running and is triggered again, the subsequent workflow will be terminated). 

 

Check this box to allow multiple instances of this workflow to run at the same time (if this workflow is running and is triggered to run again, the trigger will be successful and a 2nd instance of this workflow will begin.  There is no limit to the number of workflow instances that can run simultaneously).  

 

Thank you for your hard work FLOW team. You have a useful, feature rich product.  Hoping to see it become a little tighter within SharePoint and with global settings.  

 

Regards,

Bill 

6 REPLIES 6
Community Support Team
Community Support Team

Re: How to stop infinite loop when workflow modifies list that workflow is set to run on

Hi WillyD44,

 

Have you tried the trigger “When a file is created(properties only)”? Will it meet your needs? Using this trigger, your flow will be only triggered when a file is created but not updated.


When using the trigger “When a file is created or modified(Properties)”, to stop the flow to be triggered when the file or any other properties are modified, you may add a Condition to check if the Created time is equal to Modified time.


If they are equal, it means that the file is newly created, if they are not equal, it means that there are some modifications on the file.


After the Condition, you could add other action under If yes/If no branch according to your needs.


Please take the following screenshot for a reference:

3.PNG

 

Please have a try with it and feel free reply if you need more help.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
WillyD44
Level 8

Re: How to stop infinite loop when workflow modifies list that workflow is set to run on

Thank you for your help, but my issue is a little different.  Well after the file is created and person A modifies the file properites, then 4 minutes later person B modifies the properties...I want the workflow to NOT run because there is already an instance of it running.  

 

Ideally this would be a global setting as there could be times where I would want multiple instances of the same FLOW running concurrently.  But in my use case above, I do not. 

 

Thanks,

Bill

 

 

Community Support Team
Community Support Team

Re: How to stop infinite loop when workflow modifies list that workflow is set to run on

Hi WillyD44,

 

Thanks for clarification.

 

My understanding is that you just want the flow triggers for one modification but not every time a modification happens.


I am afraid that it might be not possible, the trigger “When a file is created or modified” will trigger the flow whenever a new file is created or a modification happens.


You may consider submitting your request at Flow Ideas Forum, hope PGs will take it into consideration in future releases:
https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Chrisstov
Level: Powered On

Re: How to stop infinite loop when workflow modifies list that workflow is set to run on

Hi WillyD44,

 

i've hit the same roadblock. I am reverting back to SP designer and WF2013. I was not able to find a workaround.

 

There are a ton of scenarios when the item is modified and it is absurd that the whole flow runs tom-to-bottom.

 

We need single-instance workflows badly. If anyone has managed to find a solution please post it here. 

WillyD44
Level 8

Re: How to stop infinite loop when workflow modifies list that workflow is set to run on

My workaround was to:

  • create 7 FLOWS (absurd and I won't use it in production).  Each workflow handles the actions I want to happen that are associated with a certain column (Document Status) status.  The reason for 7 FLOWs is that I can associate actions to each document status.  By isolating actions to certain document statuses, I can also terminate workflows that don't apply. 
  • create a copy of all key fields to compare to the original so I know if a change has happened (i.e. Field 1 and CopyField1.  By default both fields have the same value.  If a user modifies my library and changes Field 1...it will no longer equal CopyField1. At this point I know a change has occured to the Document Status field as opposed to the user adding a period in a multi-line of text field. 
  • begin each FLOW with 2 conditions (see screenshot after reading the below) 
    • Condition 1:  Does DocumentStatus field equal a certain value.  If no, that means that actions associated with the current field value do not pertain to the actions in this particular workflow.  So..I terminate the process.
    • Condition 2: I look to see if the Document Status field has changed.  If the key field has not changed, I terminate the workflow.  If the key field I am evaluating has changed (DocumentStatus does not equal CopyDocumentStatus) then I allow the workflow to continue because I KNOW that at least one of the changes in my item was a change to Document Status and I now want to run XYZ actions.  

Conditions.png

 

I'm not using this solution in production, because it is too hard to maintain.  7 workiflows with lots of logic...if something breaks or needs to be added, I'd be in trouble.  

 

Yes, I hope they add a feature to allow concurrent instances of the same workflow or not allow it as a toggle swithch for each workflow. 

 

Good luck. 

Bill

yogeshkumarPa
Level: Powered On

Re: How to stop infinite loop when workflow modifies list that workflow is set to run on

Hi All,

 

I also need single workflow instant run at a time. In my case I am triggering work flow on item update. Also in the workflow i am updating same list to maintain workflow status, custom log and other fields as per my need but my workflow gets in infinite loop when I am updating current list item in the workflow. 

 

Earlier we are using SharePoint designer/ Nintex workflow and it works fine for us.

 

Can you provide a simple action like set field value which will update the list item but not trigger workflow update event?

 

This is my POC to convert SharePoint designer/Nintex workfow to Microsoft flow. We need to convert thousants of workflow in future if POC gets success.

 

Appriciate your help to provide workaround for this senario.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us 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!

Top Kudoed Authors
Users Online
Currently online: 284 members 4,891 guests
Please welcome our newest community members: