Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

How to make my flow wait the end of the foreach

(0) ShareShare
ReportReport
Posted on by 33

Hi folks!
I have flow to export data to a excel file, it receives a json as parameter from the powerapps and return the file path.  in the middle of it, it's had a "apply to each" to add the json objects into the rows of an excel file. but when it returns the file path to download the for each it's not done yet and the powerapps download a file with only two or 3 lines of data. So, to get the complete file I have to wait some time and then go directly to path and download.

 

RaphaelMelo_0-1710181744487.png

 

Categories:
  • David_MA Profile Picture
    11,557 Super User 2025 Season 1 on at
    Re: How to make my flow wait the end of the foreach

    Looks like I was at least on the right track with the do until. 🙂

  • wyattdave Profile Picture
    406 Super User 2025 Season 1 on at
    Re: How to make my flow wait the end of the foreach

    It looks like the issue is the Power App is timing out the flow. The App will only wait upto 2 minutes (I think). You need to do a polling flow, I wrote a guide here.

     

    https://dev.to/wyattdave/how-to-power-apps-getting-polling-update-from-file-upload-547g

  • David_MA Profile Picture
    11,557 Super User 2025 Season 1 on at
    Re: How to make my flow wait the end of the foreach

    I don't know that this will solve the issue, but I would create an int variable and populate it with the value of a length expression to tell the flow how many rows of data you have in your JSON data (maybe name it total rows). Then create another integer variable and set the default value to 0 (zero) (maybe named processed). Then in the apply to each, increment "processed" by 1 after each item is completed. Put the whole Apply to each within a Do until and set the logic to be where rows equals processed.

     

    This isn't something I have tried before because I don't understand how your flow moves on to the next action before the apply to each is completed. It will be interesting to see if this solves the issue in case I encounter this.

  • RaphaelMelo Profile Picture
    33 on at
    Re: How to make my flow wait the end of the foreach

    The delay doesn't solve the problem, cause if the "apply to each" runs longer than it the problem will continue.

  • Andrew_J Profile Picture
    1,962 Super User 2025 Season 1 on at
    Re: How to make my flow wait the end of the foreach

    @RaphaelMelo 

     

    Add a delay step in the flow and set this for five minutes.

     

    Regards,

     

    Andrew

     

     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492