Showing results for 
Search instead for 
Did you mean: 
Memorable Member
Memorable Member

Apply to each loop won't exit

I'm building a replacement for SharePoint 2010's "Collect Feedback" workflow. Actually, I've built a few of them, but in this scenario, I'm trying to do something a little different. I have a document library ("docs for feedback") and two lists ("reviewers" and "feedback"). What the department wants to do is start the feedback collection with a deadline specified at the time they start the flow. So, I've got a "for a selected file" trigger with an input of "Deadline Date" (there is no input that supports date AND time yet - the flow sets the deadline to be 5:00 PM local time on the date specified). The rest of the flow (in general terms) is:

  1. Get all of the items from the Reviewers list and put their email addresses into an array variable (varReviewerEmails)
  2. Calculate the deadline (in local format for inclusion in the Approval message and in UTC/roundtrip format for the delay until action)
  3. In an "Apply to each" loop, perform the following for each item in the varReviewerEmails array:
    1. Create an approval (NOT "Start and wait")
    2. Then, there are two parallel branches
      1. One waits for the approval to complete, then writes the feedback into the "Feedback" list \
      2. Another that waits for the deadline, then checks to see if feedback has been received from the "current item"; if not, write an entry indicating that no feedback was provided
    3. After the Apply to each completes, update the document properties to indicate that the process is complete The problem is that the Apply to each (screenshot below) doesn't "end" unless all of the reviewers respond. That is, when the deadline passes, the "no feedback received" entry gets created for any reviewer that has NOT responded, but the loop doesn't exit.

I've thought through other ways to achieve this, but keep hitting walls. I need to assign them each an "approval" because each needs to be handled individually. If I were to have one approval assigned to all of the reviewers, it would either need to be "first to respond" or "wait for all responses", neither of which works for this process. Here's a screenshot of the "Apply to each" part of the flow. I'm almost certain that the solution to this problem is in there, but I can't find it.


Dual Super User
Dual Super User

Did you set the Apply to Each settings for Parallelism?  Otherwise it will wait for each reply to be returned and for the deadline to be reached before it will exit the loop.



If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Sorry, I forgot to mention that. Yes, I set "Concurrency Control" to "On" and the "Degree of Parallelism" to 50 (see below). Prior to that, it would wait for the deadline or a response to generate the "next" approval.




That's one issue, but it will still wait until both parallel branches finish.  so it will wait until each deadline passes even if the user responds to the approval before proceeding.  Setting the parallelism means that they will all operate in parallel, which is good.  But it will still wait for the Deadline.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thanks, Peter. I understand that, and I'm OK with that behavior. But, now that I'm looking at it again, because they are parallel branches, it's going to wait for BOTH of them to finish. What I need is an OR gate in there. So, for each Reviewer, wait for them to respond OR the deadline. The problem is that I can't think of how to create that in Power Automate within that Apply to Each loop.


I can think of another approach (which I've used elsewhere) which would be to create the "feedback" item and have a separate flow that's triggered on that item being created to send and wait for the response or the deadline. Because it would be a single approver, there wouldn't need to be an "Apply to each" loop, which simplifies the whole thing a bit. It would just mean going back to the drawing board completely...or almost completely.

I've done something similar with a Do Until Loop instead of an Apply to each.  In the deadline I do a pause loop and then check on the deadline or that the approval is complete (handled via variable).  If either is done I exit the do until loop.  Taht way the Deadline loop can complete earlier.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I thought about the variable to track the approval completion, but I don't think it'll work because the variable is "shared" by each iteration of the loop. So, let's say reviewer "A" responds and "varReviewComplete" is set to "true"; reviewer "B" does nothing, so when the deadline hits, the flow checks varReviewComplete and sees that it's set to "true", thus NOT creating the "no feedback" entry. 


Thinking back to how the "Collect Feedback" workflow worked in SP2010, I think the workaround I mentioned may be the closest replication of that. In that OOTB workflow, it created a "Task" assigned to each recipient. In Power Automate, this can be split into two steps:

  1. Create the "feedback" item for each reviewer - this is a very simple flow.
  2. That item being created triggers a separate flow that creates the approval assigned to the specific reviewer
    1. Within that flow, have the two parallel branches that are now within the Apply to each
    2. Because they are NOT within an Apply to each, I can add a Terminate action to end the flow when either event occurs

The only problem is "closing the loop" and going back to the item needing review to mark the process as "done". Although, I could just add a step in the first flow to wait until the deadline (plus a minute, just to be safe) and update the status. Or, set a column in that library for "number of reviews" - as each review is done or times out, it decrements that value. Although, that could result in multiple flows trying to update the same item at the same time and failing. 

The variable won't work if you are doing parallelism.  I was doing a serial flow.


But it sounds like you are one the right track.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (3,582)