cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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.
5 REPLIES 5
Super User
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 anybody solved your question, remember to mark its post as a solution!

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 

 

Super User
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 anybody solved your question, remember to mark its post as a solution!

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 387 members 5,960 guests
Please welcome our newest community members: