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
uyentpk
Frequent Visitor

Re: Loop through an array variable that is created in MS Flows

@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

6 REPLIES 6
Community Support
Community Support

Re: Loop through an array variable that is created in MS Flows

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.
uyentpk
Frequent Visitor

Re: Loop through an array variable that is created in MS Flows

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

uyentpk
Frequent Visitor

Re: Loop through an array variable that is created in MS Flows

@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

Community Support
Community Support

Re: Loop through an array variable that is created in MS Flows

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.
Super User
Super User

Re: Loop through an array variable that is created in MS Flows

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/

 

Administrator
Administrator

Re: Loop through an array variable that is created in MS Flows

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
Microsoft Power Automate Community Manager
Are YOU a member of your local Power Automate User Group?
Fill out This Form to claim your Community User Group Member Badge!

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (5,274)