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

11 REPLIES 11

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,093)