cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
uyentpk
Frequent Visitor

Loop through an array variable that is created in MS Flows

Hello,

 

In my flow, I create an array (ManagerEmails) using Initialize Variable. Then, I have a ForEach loop that appends email into the ManagerEmails array. After the first ForEach loop finishes, I have another ForEach loop that loops through the ManagerEmails array variable. How do I access the elements of the ManagerEmails array

Screen Shot 2018-08-03 at 19.43.48.png

1 ACCEPTED SOLUTION

Accepted Solutions

@v-yamao-msft 

 

ok, based on your suggestion, I think I figured it out. For those who wondered, instead of appending the email directly to the array variable, I write an expression using concat which concatinate the email with an empty string. Somehow it works. The expression I used was 

 

concat(items('Apply_to_each')?['Manager']?['Email'],'')

View solution in original post

7 REPLIES 7
v-yamao-msft
Community Support
Community Support

Hi @uyentpk,

 

What’s the type of the variable? Have you set it as String?

 

In the following flow, I set the variable type as String, and I can select the variable for the To field of the Send an email action.

 

Please check the following screenshot for a reference:

1.PNG

 

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yamao-msft,

 

The type of my variable is an array. Then, in the first apply to each, I append the email of each manager to the array variable I have. The manager is a person or group field in SharePoint.

 

In your example, I see that you set your variable to String. Is there anyway that I can make the array understand the values I append to it are string because I want to make a list of emails. Please see my screenshots for more details. Thank you for your help 🙂

 

Screen Shot 2018-08-06 at 02.19.46.pngScreen Shot 2018-08-06 at 02.20.14.pngScreen Shot 2018-08-06 at 02.26.46 (2).png

@v-yamao-msft 

 

ok, based on your suggestion, I think I figured it out. For those who wondered, instead of appending the email directly to the array variable, I write an expression using concat which concatinate the email with an empty string. Somehow it works. The expression I used was 

 

concat(items('Apply_to_each')?['Manager']?['Email'],'')

Hi @uyentpk,

 

Thanks for sharing. I am glad to hear that you figured it out.

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HI @uyentpk,

 

Why don't you use the select action to transform the data?

 

Here is an example:

 

https://veenstra.me.uk/2018/06/04/microsoft-flow-how-to-make-your-flows-perform-better/

 

GabrielStJohn
Community Champion
Community Champion

Hello, @uyentpk!

Thank you for posting on the Flow Community Forum! Have you had an opportunity to apply @Pieter_Veenstra‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!


Thank you for being an active member of the Flow Community!

-Gabriel
Flow Community Manager

- Gabriel
Community Manager
Power Automate | Power Virtual Agents
Super User Program Manager



nksse
Frequent Visitor

I found the solution in this post to work really well. Except that I feel Power Automate should simply be able to iterate over one of its own arrays.

Looping through an Array in Power Automate – Mrs Toni Gee (tkg.nz)

The solution is simple though: Parse the array as JSON first.

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!

Top Solution Authors
Users online (3,222)