How can I empty an array variable in Azure Logic Apps?

Z.K.Z 221 Reputation points
2022-04-30T19:12:55.127+00:00

Hello,

I have create a For Each Loop in Azure Logic Apps. Before, I initialized an array variable and I want to write different infos into it with each iteration. For each new iteration I would like to clear the array variable. For example we have 3 iterations. For the first one I want to get ["red", "blue", "green"], emptying array variable, next ["yellow", "blue", "red"], emptying array variable again and for third ["blue","yellow","orange"].

I have tried to use Set variable in the For each activity with the following values:

array('')
array([])

but each time I get a result like this ["", "yellow" "blue", "red"], ["","blue","yellow","orange"]

Any suggestions how I can clear the array variable without the "" at the start?

Thanks and best regards

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,252 questions
0 comments No comments
{count} vote

Accepted answer
  1. Bruno Lucas 4,431 Reputation points MVP
    2022-05-02T02:25:14.41+00:00

    Hi, you may not need to do that depending how you arrange the flow, but if you want to try clearing an array, click on the "set value" of "set variable" and switch to "expression", type null and click ok. Another aproach is creating a second array variable, keep it empty and assign the original array to the value of the second array: https://powerusers.microsoft.com/t5/Building-Flows/Clear-array-variable-in-a-flow/m-p/82097#M8153

    198131-image001.png

    3 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.