Terminate Control : Power Automate/Flow
Have you ever thought of terminating power automate/flow if condition is not met?
Recently I have come across this scenario and I used ‘Terminate’ control to achieve this.
Terminate control gives you option to set the status (Failed , Succeeded , Cancelled , Custom Value ) .
If you select Failed , it gives you option to provide error code and error message.
In this way , we can terminate the flow using ‘Terminate’ control if condition is not met.
In my case, I want to terminate the flow based on work order status value . Have a look at the below image for reference.
Note :
Terminate control will terminate the whole flow. We cannot use it to terminate any specific branch .
If you choose ‘Enter custom value’ for Status, It will throw error while saving the flow(see below image for reference). Hoping that
Microsoft will fix this soon.
This only works if you use one of the three preset status codes.’Failed, Cancelled, Succeeded'.
Hope it helps!
Comments
-
Terminate Control : Power Automate/Flow
A plain text custom value will always throw an error. It needs to match one of the options for the status of the flow run, which are only Succeeded, Canceled, or Failed. If you enter a custom value here like "Rejected by User" or something like that, it would not match a valid selection for the status of the flow, meaning that when looking at your flow runs you would have some that were just blank.
What I do wish is that you could add a code and a message to "canceled" for auditing. So I can quickly pull up my flow and see if a flow failed that it actually failed and didn't just reach the terminate action of my flow. My example is an approval flow. If the approval request is rejected, I want the flow to kick off an email to the requestor and stop performing actions, so I added the Terminate control. Marking it as Succeeded is misleading because a Team is created at the end of the flow, so we'd like any flow that succeeds to represent the number of Teams that were created by the flow. If we terminate them as "Failed" then we can't easily identify what failed and what was rejected at the approval stage, but if I use canceled, I can't add a description for why. In this case I would say "Request Canceled by Approver" or something along those lines.
-
Terminate Control : Power Automate/Flow
The purpose of the "Custom Value" option is to dynamically set one of the static selections with an expression to reflect root cause for termination. For example, a single termination control at the end of a flow would show "Cancelled" if a condition were not met or "Succeeded" if so.
Example:
-
-
-
-
-
-
-
-
Terminate Control : Power Automate/Flow
If it's not supported it should not show up as it is confusing. Is there any news about this issue?
*This post is locked for comments