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

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

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

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 41 members 4,920 guests
Please welcome our newest community members: