web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / cancel/terminate/escap...
Power Automate
Unanswered

cancel/terminate/escape ForEach(ApplyToEach) Loop inside child flow

(0) ShareShare
ReportReport
Posted on by 45

So I'm stuck on a situation where I have a parent and a child flow. Parent flow waits for a child flows response. Child flow responds success when child flow run is completed successfully. However, I have an approval process within the child flow that is inside a ApplyToEach(ForEach) loop, and I need to exit this foreach loop. "Terminate" action cannot be used inside a foreach loop. Hence I tried using "CancelFlowRun" action. This works by cancelling the child flow, but the issue is it sends back no response to the parent flow. Parent flow keeps on retrying to start the child flow. Now I have also turned the Retry Policy to "None". Which means parent flow will not retry to start the child flow. But the issue is the parent flow fails due to the fact child flow did not respond because it was cancelled. And we cannot use Respond to flow option or Response HTTP option from child flow within a ForEach loop, this is not allowed.

 

Is there any suggestion. I do not want to rewrite my entire flow, took a lot of time and effort 😥

Categories:
I have the same question (0)
  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    Hi @MoshinK786 

    Declare a boolean variable at the top of your flow with it's default set to false e.g.

    DJ_Jamba_0-1716908132651.png


    In your Apply to each loop, the first action should be a condition to check that StopLoop is false.
    After each iteration in your Apply to each loop, add another condition that should determine whether you should continue processing the remaining loop items. If it should not continue, set your variable to true. e.g.

    DJ_Jamba_1-1716908723878.png

     

  • MoshinK786 Profile Picture
    45 on at

    Hi @DJ_Jamba ,

     

    So now I have ran into an issue where only maximum of 8 nesting condition is allowed. I cannot use IfThenElse condition anymore inside the ApplyToEach. 😥

     

    MoshinK786_0-1716949019978.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 251 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 239

#3
Expiscornovus Profile Picture

Expiscornovus 220 Most Valuable Professional

Last 30 days Overall leaderboard