cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
binki-dcx
Advocate I
Advocate I

Automatic nested apply to each breaks flow

I was building a flow and it looked like this:

 

binkidcx_0-1660402688824.png

I only intentionally added one Apply to Each, but when I selected “Message ID”, it automatically added the nested one. It seems like the the UI thinks that the Message ID is an iterable. When this flow ran, it gave me an error (sorry, the exact step names are different because the above is a recreation):

binkidcx_1-1660402771040.png

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_2')?['id']' is of type 'String'. The result must be a valid array.

 

When I was creating the flow, I was suspicious of the nested apply to each. I knew that the Message ID was a string and not an array. And then when the flow finally triggered later, I got that exact error back!

 

Why does the system automatically create this extra nested flow? When I was creating the Apply to Each, I selected the Message ID. I know that the Message ID is a member of an item within an Array. Since I want to access that member from multiple steps in the loop, the following makes more sense. Why doesn’t the system just do that for me instead of the weird nested loops thing?

 

binkidcx_2-1660402943955.pngbinkidcx_3-1660402977044.png

Apply to each + compose makes a lot more sense for this. Can someone explain why the automatic behavior is to use nested loops?

0 REPLIES 0

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,107)