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

Hello @DanielAmico

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

** Update - I have written a Blog on this concept **

Power Automate – Limit Runs to Trigger One at a Time – Flow Alt Delete – Josh Cook [Microsoft MVP]

—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!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

21 REPLIES 21
DanielAmico
Advocate IV
Advocate IV

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

v-xida-msft
Community Support
Community Support

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.
Germinal
Frequent Visitor

Has this been solved?

I've got the exact same issue.

Mike2500
Impactful Individual
Impactful Individual

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. 

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

Jcook
MVP

Hello @DanielAmico

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

** Update - I have written a Blog on this concept **

Power Automate – Limit Runs to Trigger One at a Time – Flow Alt Delete – Josh Cook [Microsoft MVP]

—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!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Anonymous
Not applicable

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

Awesome @Anonymous 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!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





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 .

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.

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!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





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?

 

@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!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





@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

@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.

Anonymous
Not applicable

@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

RameshMukka
Post Prodigy
Post Prodigy

I have a State Machine Flow on a SharePoint list which goes with 4 different approvers. Any time an approver rejects it, the flow goes back to requestor with custom approval actions "Submit for Approval" and "Withdraw". Here the requestor can make changes to the list item and "Submit for Approval" again. I dont want any flow to be triggered again here. I am already using a flag (StartWF text column) to decide whether to run the flow or not during the flow run. During this entire process, if my List item which is under approval process is modified, my flow is triggered again causing parallel runs which is a great confusion. How should I avoid this? Does Concurrency control setting help me here? I dont want flows to be queued for a given item while a flow is already running on that item.
Anonymous
Not applicable

Hi Josh,

 

I tried to implement your solution but I get an error in my flow. The first instance works fine, but the subsequent flows fail. I get the below error when I am trying to create a file in SharePoint: 

{"statusCode":400,"headers":{"Vary":"Origin","X-SharePointHealthScore":"3","X-MS-SPConnector":"1","X-SP-SERVERSTATE":"ReadOnly=0","DATASERVICEVERSION":"3.0","SPClientServiceRequestDuration":"64","SPRequestGuid":"5b5735a9-cf16-4f77-8359-f2a8e819caae","request-id":"5b5735a9-cf16-4f77-8359-f2a8e819caae","MS-CV":"qTVXWxbPd0+DWfKo6BnKrg.0","Strict-Transport-Security":"max-age=31536000","X-FRAME-OPTIONS":"SAMEORIGIN","Content-Security-Policy":"frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;","MicrosoftSharePointTeamServices":"16.0.0.21402","X-Content-Type-Options":"nosniff","X-MS-InvokeApp":"1; RequireReadOnly","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Cache-Control":"max-age=0, private","Date":"Thu, 17 Jun 2021 09:27:14 GMT","P3P":"CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"","X-AspNet-Version":"4.0.30319","X-Powered-By":"ASP.NET","Content-Length":"376","Content-Type":"application/json","Expires":"Wed, 02 Jun 2021 09:27:14 GMT","Last-Modified":"Thu, 17 Jun 2021 09:27:14 GMT"},"body":{"status":400,"message":"A file with the name Shared Documents/Solution Testing/CreatedDocs/New file b6706584-9279-4ab6-afff-e45885d78434 already exists. It was last modified by i:0#.f|membership|XXXXXXX on 17 Jun 2021 02:27:07 -0700.\r\nclientRequestId: 5b5735a9-cf16-4f77-8359-f2a8e819caae\r\nserviceRequestId: 5b5735a9-cf16-4f77-8359-f2a8e819caae"}}

Before I tried using the concurrent suggestion the flows used to run simulaneously and I got the below error:

{"statusCode":400,"headers":{"Vary":"Origin","X-SharePointHealthScore":"2","X-MS-SPConnector":"1","X-SP-SERVERSTATE":"ReadOnly=0","DATASERVICEVERSION":"3.0","SPClientServiceRequestDuration":"58","SPRequestGuid":"413e8b7e-25f0-4f24-81ef-1fd5e886ed4d","request-id":"413e8b7e-25f0-4f24-81ef-1fd5e886ed4d","MS-CV":"fos+QfAlJE+B7x/V6IbtTQ.0","Strict-Transport-Security":"max-age=31536000","X-FRAME-OPTIONS":"SAMEORIGIN","Content-Security-Policy":"frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;","MicrosoftSharePointTeamServices":"16.0.0.21402","X-Content-Type-Options":"nosniff","X-MS-InvokeApp":"1; RequireReadOnly","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Cache-Control":"max-age=0, private","Date":"Wed, 16 Jun 2021 09:08:41 GMT","P3P":"CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"","X-AspNet-Version":"4.0.30319","X-Powered-By":"ASP.NET","Content-Length":"179","Content-Type":"application/json","Expires":"Tue, 01 Jun 2021 09:08:41 GMT","Last-Modified":"Wed, 16 Jun 2021 09:08:41 GMT"},"body":{"status":400,"message":"Error in the application.\r\nclientRequestId: 413e8b7e-25f0-4f24-81ef-1fd5e886ed4d\r\nserviceRequestId: 413e8b7e-25f0-4f24-81ef-1fd5e886ed4d"}}

 This is what my flow looks like. It is failing at the create file part of the apply to each. The flow works correctly for the first run, then fails for the other consecutive flows when the trigger is initiated at the same time/a short time apart from each other. If I leave 15 seconds between triggers it always runs correctly so I am not sure what is going wrong.

 

This is using the concurrent technique set to 1:

 

freddiejoseph1_0-1623924683890.png

 

If I manually leave 15 seconds between triggering the flow it works just fine:

 

freddiejoseph1_1-1623924743202.png

 

 

Any suggestions? I have asked the question here: https://powerusers.microsoft.com/t5/Building-Flows/Flow-fails-when-triggered-multiple-times-in-a-sho... but no one has come back to me.

 

Thanks,

 

Freddie

 

 

Nata123
New Member

Hi everyone

 

I  set my workflow to run only one instance at a time. And it works fine, except that not all flow instances have been executed. 

I created 130 instances in dataverse table, and for each instance on creation starts a workflow. The problem is that 2 days later I am still missing about 50 workflow instances to be executed. Any clue how I can see the status of missing workflow  instances? They are nor failed or in progress, they are just not there. Last run was 19 hours ago.

 

Thanks in advance!

Helpful resources

Announcements

Power Platform Connections - Episode 7 | March 30, 2023

Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Dian Taylor, alongside the latest news, product reviews, and community blogs.     Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.  

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.  Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik  Heartholme     AaronKnox  okeks      Matren   David_MA     Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365   Dorrinda   G1124   Gabibalaban   Manan-Malhotra   jcfDaniel   WarrenBelz   Waegemma   drrickryp   GuidoPreite    If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Register now for the Business Applications Launch Event | Tuesday, April 4, 2023

Join us for an in-depth look into the latest updates across Microsoft Dynamics 365 and Microsoft Power Platform that are helping businesses overcome their biggest challenges today.   Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating, and creating using AI-powered capabilities, driving productivity with automation—and building towards future growth with today’s leading technology.   Microsoft leaders and experts will guide you through the full 2023 release wave 1 and how these advancements will help you: Expand visibility, reduce time, and enhance creativity in your departments and teams with unified, AI-powered capabilities.Empower your employees to focus on revenue-generating tasks while automating repetitive tasks.Connect people, data, and processes across your organization with modern collaboration tools.Innovate without limits using the latest in low-code development, including new GPT-powered capabilities.    Click Here to Register Today!    

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.   Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.      Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Users online (6,742)