web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Clearing an Array

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi I have an issue when clearing an array.

I append data to an array but it needs to be cleared every loop. To do this I made an empty array variable and set it as the value of the array. Problem is when I use this, my flow runs forever and never stops. Removing this means the flow completes but then data keeps being appended to the array which I don't want to happen.

 

Any other ways I can clear the array?

Categories:
  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Anonymous,

     

    Just to double check. Which action did you use to empty the array. Was this the Set variable action and did you use [] as the value to make it empty?

     

    setvariable_empty.png

     

    If so, can you share a couple of screenshots of the rest of your flow?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for replying,

     

    I have tried using the set variable to set the arrays value to [].

    I also made an array variable that was initialized with no value and [], all cause the flow to never end.

    I was clearing the array straight after I use it. 

    The point of the flow is to add an attachment to a sent email, I tried doing this with SharePoint's get file content from path but I had to hard code it with the array as sometimes get file content wouldn't get the files (so the array value is very long). The array needs to emptied or else they receive multiple email attachments.

     

     

    Cameron4UCS_1-1632344041297.png

     

    Cameron4UCS_0-1632344014791.png

    Cameron4UCS_2-1632344074769.png

    Cameron4UCS_3-1632344100029.png

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I managed to set the variable to clear it instead of appending it then clearing it later on.

    It is working now thanks for the help.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have just tried again and it has stopped working. 

    Trying to set or clear the array results in the flow continuously running, but appending to the array works fine.

    Unless the length of the string I am passing into the array is the issue otherwise I am not sure.

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Anonymous,

     

    Strange issue. Can you share a screenshot of the whole setup of your flow? 

     

    Let me rebuild it in my development environment and see if I can reproduce your behaviour. After that I can try and find a solution for it.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for your help.

    I managed to solve it by using the file get content from path dynamic content as the value for $content inside the array. It let me set the array without issue after that.

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Anonymous,

     

    Great to that you manage to solve it. Saves me some time building for a reproducing the issue 😁

  • testasdfasfsafa Profile Picture
    309 on at

    I sincerely do not understand why Microsoft refuses to provide an Empty Array function or action...

  • danishpowerapps Profile Picture
    66 on at

    I have had the same issue.

    Solution:
    Step 1 - Initialize an empty variable (same type as the one you wish to clear)

    Step 2 - Set variable (the one you wish to clear) and give it the value of the initialized (empty) variable

    It's all described here:
    https://powerusers.microsoft.com/t5/Building-Flows/Clear-array-variable-in-a-flow/td-p/81772

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 298 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard