cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Collector
Kudo Collector

Clear array variable in a flow

I have a working flow with for each loop. In loop i'm using array variable to build a list of item to send it in e-mail. In next loop i need to use the same variable, but I want to start adding to empty array. How to set array variable to be "blank new" for next iteration of loop? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Clear array variable in a flow

Hi @Kamil,

 

Could you please share a screenshot of your flow's configuration?

Do you want to set the array variable to empty for next iteration of loop?

 

I think a empty array variable could achieve your needs, I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Variables-> "Initialize variable" action, Name set to GlobeArray, Typre set to Array and Value set to empty.
  • Add a "Get items" action, specify Site Address and List Name.
  • Add a "Apply to each" aciton, input parameter set to output of the "Get items" action. Within "Apply to each", add a "Append to array variable" action, Name choose GlobeArray, Value set to Due Time dynamic content of the "Get items" action.
  • Under "Apply to each" action, add a "Compose" action, Inputs set to GlobeArray variable.
  • Add a Variables-> "Initialize variable 2" action, Name set to EmptyArray, Type set to Array and Value set to empty.
  • Add a "Set variable" action, Name choose GlobeArray variable, Value set to EmptyArray variable.

Image reference:4.JPG

 

5.JPG

The flow works successfully as below:6.JPG

The value of GlobeArray variable after first iteration of loop as below:7.JPG

The value of GlobeArray variable after clearing array as below:8.JPG

Best regards,

Kris

 

 

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

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

Re: Clear array variable in a flow

Hi @Kamil,

 

Could you please share a screenshot of your flow's configuration?

Do you want to set the array variable to empty for next iteration of loop?

 

I think a empty array variable could achieve your needs, I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Variables-> "Initialize variable" action, Name set to GlobeArray, Typre set to Array and Value set to empty.
  • Add a "Get items" action, specify Site Address and List Name.
  • Add a "Apply to each" aciton, input parameter set to output of the "Get items" action. Within "Apply to each", add a "Append to array variable" action, Name choose GlobeArray, Value set to Due Time dynamic content of the "Get items" action.
  • Under "Apply to each" action, add a "Compose" action, Inputs set to GlobeArray variable.
  • Add a Variables-> "Initialize variable 2" action, Name set to EmptyArray, Type set to Array and Value set to empty.
  • Add a "Set variable" action, Name choose GlobeArray variable, Value set to EmptyArray variable.

Image reference:4.JPG

 

5.JPG

The flow works successfully as below:6.JPG

The value of GlobeArray variable after first iteration of loop as below:7.JPG

The value of GlobeArray variable after clearing array as below:8.JPG

Best regards,

Kris

 

 

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

View solution in original post

Highlighted
Kudo Collector
Kudo Collector

Re: Clear array variable in a flow

Thanks for help.

Highlighted
Regular Visitor

Re: Clear array variable in a flow

You can also do a Set Variable with a value of null.

Highlighted
Advocate II
Advocate II

Re: Clear array variable in a flow

I have used the approach of setting the variable equal to null, however it stopped working about a week ago. Has the syntax of the "null" function changed?

Highlighted
New Member

Re: Clear array variable in a flow

Hi

 

You can just set variable to "[ ]" this will empty you

 

Thanks and Regards

Vivek Verma

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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!

Top Solution Authors
Top Kudoed Authors
Users online (5,926)