Finding out that you have a scheduled flow in Power Automate, that just continue to run and then the next flow does the same and all of a sudden, you have a gazillion flows running and never stopping. Well according to the Power automate limits, they will be cancelled after 30 days.
But you don’t have the option to turn the flow off and the wait 30-days until you can turn it back on again – I assume. And you have a list that look like this:
The behavior mostly happens, when a workflow starts, before the previous has finished. You can take a look at this article by Pieter Veenstra on how to troubbleshoot the flow to dig deeper into the how and the why. Here is a few ways to prevent it and to deal with it.
- Set the degree of parallelism to 1, then you will only have one flow running. Then you will discover immediately if it hangs.
- Cancel all the running flows
- Make a copy of your flow, export it, then import it and delete your old flow (not a fan of this option but it will work)
- Check if lists or items or sites etc. Exists before you try to create them. If you need to check for new items in a list and run stuff for each item, then make a condition to only run, if there is any items.
- Make a list, with a single item that reads “locked” or “Unlocked”, then at step 1, check if item is unlocked, if not, terminate the flow. If “unlocked = true, then set it to locked, and then run flow. As a final step, set the item back to “unlocked”.
Set the degree of parallelism to 1
- If you have a recurring flow, click on the steps menu “…” and the “Settings”.
2. Activate “Concurrency Control” and then set the “Degree of Parallelism” to 1
Cancel all the running flows in Power Automate
When you open the console in edge you will have the option to input some scripts to handle the output on the screen. Getting some help in the comments, the fastest way to achieve this is to follow the instructions below:
- Navigate to the flow in question
- Click on “All runs”
- Filter the view to only show the running flows
- Open the console in the browser (hit F12 and the select console)
- Paste in the code below. For some reason I need to paste the jquery part twice before the actual action code, but it works like a charm. Depending on the number of flows you have running, this can take quite a while.
//Include jquery (you may need to paste this following twice)
var jq = document.createElement('script');
jq.src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// Cancel all running flows ( This part you only paste once)
confirm = function () {
return true;
};
setInterval(function () {
$(".fl-StatusInCell:contains('Running')").parent().parent().parent().find('.ms-DetailsRow-cell').first().click();
$(".fl-StatusInCell:contains('Running')").parent().parent().parent().find('.ms-DetailsRow-cell').last().click();
$(".fl-StatusInCell:contains('Running')").parent().parent().parent().find('.ms-DetailsRow-cell').first().click();
$('button[name="Cancel flow run(s)"]').click();
},
3000);
Leave a Reply