cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
milind
Frequent Visitor

Setting string variable to empty

I want to set string variable to empty.  I am initializing string viriable empty then I am appending that variable in loop but before appending loop each time I want to make it empty.

 

Is there any way to do that

 

1.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

Hey @milind 

 

You can use the expression editor to set the value as null and it will empty that variable: 

ddew.PNG

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

12 REPLIES 12

Hey @milind 

 

You can use the expression editor to set the value as null and it will empty that variable: 

ddew.PNG

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

thats wonderful solution 🙂 

This approach suddenly stopped working for me about a week ago... has the syntax of the null functoin changed?

Hey @Matt_Markahm 

 

I have made another test on my side and it is working as expected. Are you facing any errors or issues? Can you share a screenshot of that? 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

@yashag2255 @

I am using a string variable to capture a set of values stored in a SharePoint multi-select list, put them together into a text field and then print that field to a MS Word template for a report.

 

I initialize the variable:

Initializing the String VariableInitializing the String Variable

Then I use a loop to append values to the string:

Append Text to String.PNG

 

Once the value of the string variable has been written to an instance of the report, I am trying to clear it using the method previously described:

Null the String Variable.PNG

 

This approach was working, but lately it has been failing as you can see in this example of the results from one of the generated Word files:

Output of Variable.PNG

 

There should be no repeats in this list if the string variable is being set to null between each iteration of the loop... instead it seems that the list just grows and grows as each record's list is appended to the variable. Any suggestions would be greatly appreciated.

 

Thanks!

Matt

 

Hey @Matt_Markahm 

 

Is null string a variable that you created? 

 

If you observe the screenshot that I have shared, you will see that i just used null. You can do that by placing the cursor in the value and then in the expression editor, type null and choose from the filtered list. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

mleehersh
Advocate I
Advocate I

Has anyone found a new way to do this?  Using null() in the expression builder for the Set Variable step is no longer allowed, it says invalid and won't let me save it.  I need to find a way to actually clear it out.

Rick97213
New Member

I'm new to Power Automate under Windows 10 21H1 (free version). The only way I discovered to clear a string variable is to use the Clear List command. It seems to treat it as a list of characters and create a truly empty string that works with the 'is empty' IF statement.

Thank you for this!  I added this Null/clear to my solution and it worked out perfectly.

Hi @Rick97213,

what is "Clear List" command? Could you please explain? 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
tej578
New Member

tej578_0-1658840214871.png

 

this works for me

Yes. It really works for me.

Thanks

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,351)