cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NewBee117
Advocate V
Advocate V

Get the data array out of "Apply to Each"

I initialize the variable ApplytoeachOutput to an array, then set it to the array from the selection in the "Apply to each" loop, all looks fine in the loop. However, when I call the ApplytoeachOutput outside the loop, it has the same amount of items, yet the value is repeating the last row. Any idea what is the proper way to get the selected data out of the "Apply to each" loop?

    

   NewBee117_0-1620401272127.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
zaphod88
Responsive Resident
Responsive Resident

You have to replace your "Set variable" action by "Append to array". If you want to, you can also get rid of the SelectItem action and replace it by the following formula in "Append to array":

{ 
"ID": @item()?['ID'],
"Title": @item()?['Title']
}

 and so on, just insert your own need columns. The "@"-mark means it has to be insertes by expression editor.

View solution in original post

1 REPLY 1
zaphod88
Responsive Resident
Responsive Resident

You have to replace your "Set variable" action by "Append to array". If you want to, you can also get rid of the SelectItem action and replace it by the following formula in "Append to array":

{ 
"ID": @item()?['ID'],
"Title": @item()?['Title']
}

 and so on, just insert your own need columns. The "@"-mark means it has to be insertes by expression editor.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,438)