I have to create a Flow that iterates over all files in a folder (DropBox, SharePoint, OneDrive etc) and merge them together into a single PDF file.
I can retrieve the list of files, and the Muhimbi PDF service has the ability to merge files into a single PDF. However, I ran into an issue that took a while to troubleshoot.
My tests indicate that Flow's 'For Each' capability does not execute each iteration in sequence. Instead it executes multiple iterations in paralllel. As a result it is not possible to feed the output of a previous cycle (the merged document so far) into the next cycle.
With the benefits of hindsight it is easy to reproduce.
Create an Array, or something else you can feed into For Each (email attachments, files in a folder etc)
Create a 'For Each', and as a first Action add the 'Delay' option and let it wait for one minute
As a next action do something that results in a time stamp (send an email, write a file).
For 4 iterations you'd expect a total run time of 4 minutes (due to the 1 minute delay). However, you'll find that all 4 iterations finish roughtly at the same time, after 1 minute in total.
Is this parallel processing a bug or a feature? if it is a feature, can we have a switch to force the iterator to run in sequence rather than in parallel?