cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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
Highlighted
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.
Highlighted
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

Highlighted
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

Highlighted
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.
Highlighted

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/

 

Highlighted
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
Community Manager
Power Automate | Power Virtual Agents
Super User Program Manager
Power Platform Communities

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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