Flow intentions:
Recurrence once per week
Get all files in folder (currently 22 files)
Loop through each file (each file contains an array of up to 5000 items)
Create a new file with either 150 items or up to the last item if the end of the file is reached
Problems:
I am seeing that all files are placed in the correct folder with a max of 150 items as I expect. Even after the flow finishes with the 22 files, it continues and starts looping through the first file again. If it would end when I expect it to, it would take roughly 20 hours to complete.
Flow:
Is there a better way to set this up? Why is it restarting the loop when it finishes with the last file? Can this process be ran in parallel to speed up the amount of time it takes?
Your flow is going into continuous loops because of the "Apply to each".
When you use "Apply to each" action it takes an array as input and loops through each item in the array. If my array has 5 items the loop will run 5 items and like wise.
In your scenario I think the problem is that in the first or second iteration of the loop all the files are getting created, the next iterations are happening because of the number of elements in the array.
To break this you can make use of the terminate action in Power Automate, this will help you in stopping the flow execution
You can also try creating parallel branches in the flow, but I don't think that would have a major impact considering that the actions are nested in an Apply to Each loop. I would suggest use of Terminate action.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
21 | |
18 | |
11 | |
10 | |
8 |
User | Count |
---|---|
31 | |
27 | |
26 | |
17 | |
16 |