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

Allow only 1 instance of a flow to run at the same time

Hello all, I would like to know if there is a way to avoid the same flow to run while there is another instance of this same flow already running.

This is because I've noticed that when 2 or more instances of the same flow are running at the same time, the data manipulation that it's performing turns into a "complete mess". This does not happen if I wait for the running flow to complete before starting a new one. 

However, this limitation is very bad because I want to be able to share the flow w/ other people and they will eventually start it at the same time and the final result would be incorrect.

 

Basically, my flow (manually triggered) extracts some data from SQL DB (Azure), then I use an Excel template file (stored in my OneDrive for Business) w/ a table in order to be populated w/ the data from SQL. For this step, I have to first list all the rows in the table and then I loop through it and delete them all before I add the new rows that are coming from SQL.

After that, I inserted a 1-minute delay before getting the file contents /metadata and then send the excel file by email.

 

See the setup of my flow attached. 

 

I appreciate some help - as I said, what I want is to avoid this flow to be initiated at the same time because if it happens, my excel template file turns into a mess (conflicting/incorrect information is sent by email probably because one instance of the flow is inserting rows at the same time or removing rows at the same time of the other and vice versa)Setup of my flowSetup of my flow

 

 

 

Thanks, Daniel

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Allow only 1 instance of a flow to run at the same time

Hello @DanielAmico

On your trigger,
Click the 3 dots,
Now click settings.
Enable concurrency, and set it’s value to 1.

—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others




Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





View solution in original post

16 REPLIES 16
Highlighted
Advocate IV
Advocate IV

Re: Allow only 1 instance of a flow to run at the same time

Is anyone able to help? No replies until now....  Smiley Frustrated

Highlighted
Community Support
Community Support

Re: Allow only 1 instance of a flow to run at the same time

Hi @DanielAmico,

 

Microsoft Flow is multi-threaded, there is no way to detect if some other instances are running at the same time in Microsoft Flow currently.

 

I afraid that there is no way to achieve your needs in Microsoft Flow currently, if you would like this feature to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Frequent Visitor

Re: Allow only 1 instance of a flow to run at the same time

Has this been solved?

I've got the exact same issue.

Highlighted
Responsive Resident
Responsive Resident

Re: Allow only 1 instance of a flow to run at the same time

The main situation is unchanged, the same flow can be running at the same time if triggered. Two basic workarounds: 

 

1. Modify the trigger so that it won't be triggered multiple times in the same timeframe. For example. if the flow is on a schedule to run once every 15 minutes, then it won't run twice at the same time. 

 

2. Have something like a sharepoint list that tracks if the workflow is running. The first step of the workflow would be to retrieve a given list item and check the status field, for example. If the status empty, then set it to "running", and then proceed. If another flow instance runs at this point, it will see a status of "running" and will then simply exit. Of course, this isn't foolproof, as if the flows run at exactly the same time, they could wind up both reading the status of empty and proceed, though since this update process would happen quickly, the chances of a collision would be greatly reduced. 

Highlighted
Regular Visitor

Re: Allow only 1 instance of a flow to run at the same time

Same problem here... is there a idea link to vote?

Highlighted
Super User
Super User

Re: Allow only 1 instance of a flow to run at the same time

Hello @DanielAmico

On your trigger,
Click the 3 dots,
Now click settings.
Enable concurrency, and set it’s value to 1.

—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others




Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





View solution in original post

Highlighted
Resolver II
Resolver II

Re: Allow only 1 instance of a flow to run at the same time

@Jcook  thanks for this tip as it resolved an issue we were having.

Highlighted
Super User
Super User

Re: Allow only 1 instance of a flow to run at the same time

Awesome @shanemeisner glad it had helped you!

 

@DanielAmico Could you please let us know if this has solved your issue. This would be even more helpful in letting others find this answer. Thanks

@v-xida-msft

 

 

 

 





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Helper II
Helper II

Re: Allow only 1 instance of a flow to run at the same time

I almost went ahead to implement some sort of locking mechanism to control the flow runs but your suggestion saved me a lot of time and effort. Thank you @Jcook .

Highlighted
Resolver I
Resolver I

Re: Allow only 1 instance of a flow to run at the same time

Hi. Can you help clarify something?

 

Does Concurrency=1 mean one instance at a time per item, or 1 instance at a time over the whole tenant?

 

My flow is triggered when a file is added or modified (including properties) in a SharePoint library. I can't figure out (for libraries, anyway) how to leverage Trigger Conditions that rely on a particular value (the column "RunWorkflow"=True is what I usually use) because someone inevitably has the file open and I'm unable to turn that condition OFF, so any subsequent changes to the file re-trigger it.

 

I just want to prevent the workflow from running AGAIN (in parallel) on the SAME ITEM.

Highlighted
Super User
Super User

Re: Allow only 1 instance of a flow to run at the same time

Hi @mboonie 

 

Setting the Concurrency to 1 will only affect that particular Flow. This will not affect Tenant / other Flows in any way.

 

Setting to 1 will only allow the Flow to run 1 at a time. So there is 0 parallel runs. A second run will not be triggered until the previous run has finished. 





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Resolver I
Resolver I

Re: Allow only 1 instance of a flow to run at the same time

Actually, it still doesn't quite answer my particular question. I'll try to explain using a very stripped down version of my flow.

I have a flow called myFlow; it is triggered by adding or editing a document in the Documents library for my Team site. It takes three days to run because it allows 1 day for each of three edits that need to be made. Also, because additional edits are expected to be made to that same document as the flow is running, I need to have a way to stop the flow from being re-triggered for that item; it needs to run its course.

So, now I set the concurrency of the workflow itself to 1 and add a document to the library. The workflow myFlow is kicked off and the three-day clock starts ticking. And, since this is a busy library, someone creates and edits a second document in the same library on the same day, an hour later

The question I have is this: Will I have to wait three days for the workflow to finish with Document 1 before it will start on Document 2?

 

Highlighted
Super User
Super User

Re: Allow only 1 instance of a flow to run at the same time

@mboonie 


@mboonie wrote:

The question I have is this: Will I have to wait three days for the workflow to finish with Document 1 before it will start on Document 2?

 


Yes the Flow would wait until the first Run has finished. So for your use case/solution I would say Concurrency set to 1 would not be beneficial.

 

I suggest that you create a new post detailing what you have mentioned above. This will help others find your issue and try to help solve. 🙂 

 





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Frequent Visitor

Re: Allow only 1 instance of a flow to run at the same time

@Jcook, thanks a lot, I think that should work but can we clarify something; as 1 occurrence of the flow is running at a time, do the new trigger actions queue up to start a new occurrence of the flow (when occurrence is set to 1)? I mean if several actions triggering the flow are filled in more or less at the same time, does the flow run them one after one in a chronological queue? Or are the next actions ignored/forgotten?

BW

Highlighted
Helper II
Helper II

Re: Allow only 1 instance of a flow to run at the same time

@Germinal,

 

I have tried concurrency set to 1 with a CDS trigger and the flow runs are queued and in waiting status from what i have observed.

 

@Jcook, correct me if i am wrong.

Highlighted
Helper II
Helper II

Re: Allow only 1 instance of a flow to run at the same time

@Jcook 

 

Hi,

 

Will this "hold" the flow to run after first has finished or does it just not allow flow to start?

 

IE I have a flow triggered by emails, these come in from all over, I would like them to queue up.

 

Ta

 

Mark

Helpful resources

Announcements
firstImage

Now Live: 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
Top Kudoed Authors
Users online (8,497)