How Do I "Set Value" to an Empty String?

In a Server Action step, I want to perform a Set Value to assign an empty string…

So I have these lines:

empty

but the following error is thrown when the server action is run:

value

How can I do this?

In the Set Value data picker, go to code view; entering null (with no quotes) should solve it:
image

image

Null is not the same as empty string. In code view try entering ' ' (empty space) for the value.

1 Like

@Teodor, I tried doing that and Wappler doesn’t seem to save it. When I set that and save and re-open the Set Value action, then value has changed from ' ' to just be blank and then the error occurs again. I’m using Wappler version 3.2.0.

Add it without the quotes ' i added them because i can’t show an empty space here :slight_smile:

If you do this:

Then it results in:
Screenshot_14

Okay, I’ll give that a go when I’m back in that piece of code later on today.

Of course, what you are doing here is not creating an empty string, you are creating a string containing a space character.

Is there a way to initialise a Set Value to an empty string?

What exactly are you trying to achieve?

I want to initialise the variable to an empty string so I can concatenate values to it within a repeat in a repeat, so like this:

repeat A
   Set Value my_string = empty string
   repeat B
      Concatenate values to my_string
   Write my_string to a database field value

Ok i understand. Then in code view enter {{''}} this will result in an empty string.

Oh great @teodor

I see, I didn’t have the {{}} around the ''… I’ll try that option out! :slight_smile:

It worked! Thank you!

This has been improved in Wappler 5.2.1 - now you can leave the value input empty, when setting a value, so you don’t have to add an empty space in code view.

1 Like

This topic was automatically closed after 46 hours. New replies are no longer allowed.