
Error handling and TRY, CATCH, AND FINALLY are very important tasks in Programing as well in any kind of development & Microsoft Power Automate or Microsoft Flow is no different.
Error handling and TRY, CATCH, AND FINALLY can be easily implemented in MICROSOFT POWER AUTOMATE/MICROSOFT FLOW for handling different different business scenarios.
You can place your main actions inside TRY BLOCK . Due to any exceptions or errors, if TRY BLOCK will get fail then CATCH BLOCK will execute. FINALLY BLOCK will run everytime.
There is Try, Catch, and Finally Template provided by Microsoft Flow Community – https://flow.microsoft.com/en-us/galleries/public/templates/e8e028c6df7b4eb786abdf510e4f1da3/try-catch-and-finally-template
Lets understand this with an example.
- Create a flow with Manual Trigger. This is an example trigger. It can be replaced if required.

- Then add an action SCOPE. Scope Action in Microsoft power automate or Encapsulate a block of actions and inherit the last terminal status (Succeeded, Failed, Cancelled) of actions inside.

Name the scope as TRY. In Try Scope you can define main steps or actions.

- After Try Scope, add another SCOPE “Catch”. Catch Scope will execute in case of a error or exception in Try Scope. You can place your error handling logic in Catch Scope.

- Configure Run After of Catch Scope & select the option “Has Failed” = Yes


- After Catch Scope, add another SCOPE “Finally”. Finally Scope will execute always i.e. in both for failed and successful runs

- Configure Run After of Finally Scope & select the option “Has Failed” = Yes, “is Successful” = YES, “is skipped” = YES & “has timed out” = Yes

- Your final flow should look this

How to manual cancel flow when running? I am injecting code which cancel all flows as follows:
Cancelling all running flows in Power Automate – 365 HQ
CANCEL ALL THE RUNNING FLOWS
Thank you to the ever brilliant users in the “Microsoft Power Automate Community” for delivering this solution. This is just brilliant.
1. Navigate to the flow in question
2. Click on “All runs”
3. Filter the view to only show the running flows
4. Open the console in the browser (hit F12 and the select console)
5. 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);
jQuery.noConflict()
// Cancel all running flows ( This part you only paste once)
confirm = function () {return true;};
setInterval(function () {
$(“.fl-StatusInCell:contains(‘Running’)”).parent().parent().find(‘.ms-DetailsRow-cell’).first().click();
$(“.fl-StatusInCell:contains(‘Running’)”).parent().parent().find(‘.ms-DetailsRow-cell’).last().click();
$(“.fl-StatusInCell:contains(‘Running’)”).parent().parent().find(‘.ms-DetailsRow-cell’).first().click();
$(‘button[name=”Cancel”]’).click();
},3000);
Share:
From