cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Unte
Level: Powered On

Nested Foreach loops?

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'.

 

Screenshot_3.png

 

I need to get excel names from list and join rows from them to one file

1 ACCEPTED SOLUTION

Accepted Solutions
Unte
Level: Powered On

Re: Nested Foreach loops?

I found workaround using sharepoint list. But it will be good to have nested loops (at least one inside).

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: Nested Foreach loops?

Hi Unte,

 

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.

 

Best regards,

Mona Li

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Unte
Level: Powered On

Re: Nested Foreach loops?

I found workaround using sharepoint list. But it will be good to have nested loops (at least one inside).

View solution in original post

Re: Nested Foreach loops?

What was your solution?

LozzieD
Level: Powered On

Re: Nested Foreach loops?

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.

 

Anonymous
Not applicable

Re: Nested Foreach loops?

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!

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,045)