cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mccardj
Helper IV
Helper IV

Working with Variables in Apply to Each

Hi all,

 

I think I should know this but I just can't get there.

 

I have 2 apply to each loops. In the 2nd loop, I'm appending to a string variable a name, I then get the outputs of this variable in the 'Compose' below it, which is outside the 2nd loop but still inside the first loop. I'm using append because if there's 3 names in the 2nd loop I want to append the 3 names together.

 

This works fine for the 1st loop, however, when the 1st loop moves on to the next value the append variable updates with more names - this I don't want!

 

What I'm looking to achieve is for the variable to store all the names from the 2nd loop but not all the names from the 1st loop - just the 2nd loop and reset for each 1st loop.

 

Maybe append to variable isn't the right approach here?

 

I hope that makes sense!

 

 

mccardj_1-1660719365498.png

 

2 REPLIES 2
MarconettiMarco
Super User
Super User

Hello @mccardj ,

you can use two string variable, one of them to use temporary.

So, you can append all the values to the temp variable, copy it in the def variable and clear the temp variable values.

 

In that way, you can grab only the names you want.

 

If I have answered your question, please mark my post as Solved.
If you like my response, please give it a Thumbs Up.

BR,

Marco

mccardj
Helper IV
Helper IV

Hi @MarconettiMarco,

 

How do I go about clearing the temp variable values?

 

I thought it was as simple as setting the variable to null at the end of the flow but that didn't work - so I tried appending the variable to null and that didn't work either.

 

See the image below - the "Clear Participants" is setting the variable to null at the end of the flow but the variable is still appending across the 1st loop

 

mccardj_0-1660724836361.png

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (4,978)