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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Replace ApplyToEach wi...
Power Automate
Suggested Answer

Replace ApplyToEach with DoUntil,to skip the loop once a variable is set to true

(0) ShareShare
ReportReport
Posted on by 1,811 Super User 2024 Season 1
I have 3 SharePoint lists, as follow:-
 
1) Posting Process with Status ; Open, Closed
 
2) Posting Forms with Status; New, Work Order Created & Done
 
3) Posting Relation; PostingProcessID & PostingFormsID
 
 
Now i am writing the following workflow which run on schedule bases, and it do the following:-
 
1) Get all the Posting Processes which have their status as Open
 
2) Get all the related PostingRelation
 
3) Get all the Posting Forms >> loop through each form and check its status >> if its status = New or Work Order Created >> set a variable named hasOpenPostingForm = true
 
4) after the first loop iteration ends (Posting Process ApplytoEach) >> check the hasOpenPostingForm variable if it is set to false >> if so, send an email that all the Posting Forms has been completed >> and set the Posting Process status to Closed. and so on...
 
 
 
now i want to make this more efficient >> mainly to skip the Loop once the  hasOpenPostingForm  is set to true, as to us if the process still has one open form or 100 open forms it is the same.. so no need to continue processing the current iteration if this variable is set to true.
 
 
seems in power automate we can not skip ApplyToEach.. so will DoUntil help us in this case?
 
Thanks
Categories:
I have the same question (0)
  • Suggested answer
    SwatiSTW Profile Picture
    741 Super User 2025 Season 2 on at
    Here are changes you can do 
    1. Add a condition right after setting hasOpenPostingForms to true. If hasOpenPostingForms is true, use "Terminate" or "Exit" action to end the loop.
    2. Use Do Until - Replace the inner Apply to Each loop with a Do Until loop, setting the exit condition to hasOpenPostingForms = true to break the loop as soon as an open form is found.
    This approach will stop unnecessary iterations once an open form is detected.
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    Thanks for the reply, but using terminate will terminate the whole flow run and not just the current iteration, am i correct? never heard of terminating an iteration in power automate..

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard