How to null a local storage variable

HI
I know this is going to be a dumb question but how should i set a local data storage variable to null as if just created, i don't want to delete it as i think this would delete the variable not just its value (but couldnt find the answer to that either), so i have a local data storage variable Expense_id that at times i need to set back to fresh out the wrapper of null / no value, do i just do an update and set it to '' or null or NULL etc?
thanks in advance

You can just set its value to an empty string.

but how do i set it to an empty string? using the update and then '' or null? thanks

Just use an empty string when setting the value.

sorry. I am being really dumb here but I dont know how to use an empty string. I tried using the datastorage upsert and set it to have a space, but, then when i use a noload ternery operastor that fails as a space has some value I guess, if i leave it with no space then it doesn't get updated, just not sure how to give it an empty string

sorry for beig dumb :frowning:

i use this code on my page to insert new client, the smse form is also used to edit, so i use a noload to see if there is a client id

!(datastore1.data[0].Client_id)?'noload':''

and no matter what i set as the clientid in datastore its running the query as its not empty

Not sure i understand your last post.
Setting a value to 1:

<button class="btn" dmx-on:click="datastore1.upsert({$id: 1},{name: 'test', value: 1})">Set 1</button>

Setting a value to an empty string:

<button class="btn" dmx-on:click="datastore1.upsert({$id: 1},{name: 'test', value: ''})">Set empty</button>

Setting a value to a null value:

<button class="btn" dmx-on:click="datastore1.upsert({$id: 1},{name: 'test', value: null})">Set null</button>
1 Like