cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sjehanzeb
Level: Powered On

Terminate Flow inside For Each Control

My trigger is from Forms for an approval process. 

 

But before I move forward for Approval process i want to exclude some responses on a criteria based on the form. I did that but i was not able to terminate the flow after that. As Terminate control does not work in for-each condition. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Terminate Flow inside For Each Control

Hi @sjehanzeb ,

 

Terminate action cannot be used inside a for each loop.

 

Please try if the following workaround will work for you.

 

Please initialize variables in your flow, outside of the Apply to each loop, add Condition or other actions, then terminate the flow under If yes or If no branch.

1.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Dual Super User
Dual Super User

Re: Terminate Flow inside For Each Control

@sjehanzeb 

I also miss this feature, you can vote its implementation here: https://powerusers.microsoft.com/t5/Flow-Ideas/Flow-loop-break/idi-p/166125

Is your loop a do-until? If so, as a potential workaround, have you taken into account the following possibility?

Step#1: DEclare an auxiliary boolean variable 'Stop Loop' with default value to false before the for each control

Step#2: include the evaluation of this new variable in your do-until condition

Step#3: inside your do-until logic, turn to 'Stop Loop' to true whenever you want to stop new iterations

Step#4: just after the do-until, add a condition to evaluate 'Stop Loop'. In the 'true' branch, add a Terminate action block.

Hope this helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





sjehanzeb
Level: Powered On

Re: Terminate Flow inside For Each Control

I am inside the 2nd "For Each" loop. Will it work if i encapsulate the entire flow in "do-until" with a boolean check 

 

Dual Super User
Dual Super User

Re: Terminate Flow inside For Each Control

@sjehanzeb 

Can you share a screenshot with your flow details, so we can get more info on what you are working on, and see if the suggested workaround can be applied on your use case?





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





Community Support Team
Community Support Team

Re: Terminate Flow inside For Each Control

Hi @sjehanzeb ,

 

Terminate action cannot be used inside a for each loop.

 

Please try if the following workaround will work for you.

 

Please initialize variables in your flow, outside of the Apply to each loop, add Condition or other actions, then terminate the flow under If yes or If no branch.

1.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
BretCarr
Level: Powered On

Re: Terminate Flow inside For Each Control

This solution also works when you are forced to place an Approval action inside a For Each! If you set the outcome as a variable, you can then use that variable as described above to terminate a rejection. Otherwise, a rejection inside of a For Each will NOT terminate a Flow.

 

If you are curious as to why I have to place an Approval inside a For Each, I am performing a SQL stored procedure to validate a new form value against a database for existence that creates a dynamic message for the approver inside the Flow message. With the limitations of Flow and SQL connector gateways, I could not find any other way to generate my validation.Approval For Each Termination.jpg

 

Helpful resources

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,334)