cancel
Showing results for 
Search instead for 
Did you mean: 

Nested loops support

The most common issue I run into is the inability to nest foreach loops.

 

Simple case:

 

I have a table in Excel with rows of email addresses

I have a CRM entity of Users

I want to find a CRM User by email address and assign their id Guid to a column in the table

 

1. First I do a Get Rows on the Excel table

2. Next I need a foreach loop over the rows and use the email address from the Output value

3. In ideal case, i'd get list of Users from Dynamics 365, ODATA filtered by email address with limit of 1 result.

4. Continuing the ideal case, then I'd perform Update Row on the Excel row to add the userid from step 3's output to the ID column

 

Unfortunately, even if I limit results to 1, Flow still demands that I run a foreach loop on the output of the action in Step 3, so now, step 4 needs to be in a nested loop, which causes an error

4. Ideally 

Status: Completed

This work has been completed. You can read more about it here: https://flow.microsoft.com/blog/nested-apply-to-each/

Comments
Microsoft Employee

In the meantime, I've figured out how to filter to the id using Compose. I only worry that this is an inelegant workaround that might be difficult for some users to figure out.

Level: Power Up
Hey michowl,

I assume your workaround works because you're only trying to read from that row inside the loop? I'm trying to get a bunch of rows and then update the corresponding row if it exists for each item. Seems simple but impossible.
Level 10

I want Nested loop support, too.

 

In my scenario, I need "Apply to each" in "Do Until".

 

1st loop, Do Until

2nd loop, Apply to each

 

Regards,

Yoshihiro Kawabata 

 

 

Power Automate Staff
Status changed to: Planned
 
Level 10

Awesome, Status become Planned.

 

I'm waiting the Nested Loop capability.

 

Currently, I'm build nested loop flow by some Variables and a Do Until loop.

 

Regards,

Yoshihiro Kawabata