Is there a way to create loop inside another loop?
I got an error: The template action 'Apply_to_each_3' at line '1' and column '2271' is not valid. Only actions of type other than 'foreach' are allowed to be nested under an action of type 'foreach'.
I need to get excel names from list and join rows from them to one file
Solved! Go to Solution.
According to my test, you cannot add loop inside another loop in Flow so far. In that case, you could create 2 separate flows. If you need my help to know how to achieve your requirement using two flows, please describe more clearly about your needs. Thanks.
I'm guessing the solution was of this pattern: -
First workflow loops the source domain of items, running whatever actions, and writes each items into an SP list.
The list has a workflow attached triggered when a new item is added to the list. So the workflow runs for each item added to this list, which de facto implements the first loop but allows a loop inside each execution of the workflow i.e. per item.
It works, but it's a sure way to burn through your Flow quota, coz you're running a Flow for each item to implement the second inner loop, rather than a running one Flow with two for each's in it.
Which is probably why MS engineered it this way.
Nested for each is available now. Just need to create variables in the first loop to hold values from the current item, and then look at the variable within the nested for each.
I thought the current iteration of the first for each would automatically be passed into the nested for each, but alas not. At least you won't have to burn through your flow quota like wildfire now!
Note that even after 5 years this implementation was imperfect. You cannot refer to actions in a loop if that loop is nested in another loop (the technique often used to compose the results from loop iterations.
Keep up to date with current events and community announcements in the Power Automate community.
Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.
Check out the latest Community Blog from the community!