Local Storage Syntax

I would like clarification on the syntax for Local Storage.

I am trying to store the first name of a selected customer. The array name is table2. I want the stored value to be named "Sfirst".
So I have created a Resource called "GetFirst" with the code
{{ localStorage.setValue ("Sfirst", table2.first) }}

When I activate this code, I get an SQL Error Message.

What am I doing wrong?


Hello @mdsmith1,

Please could you share a screenshot of the error message you get?

Here is also documentation on how to use localStorage to save values

Here is the screen shot. The array name is table2, the field name in the array is "first". I am trying to save this to a variable "Sfirst".

You can see the error message at the bottom.

Hello @mdsmith1,

The code is being run in the wrong place.

Please create a "Javascript Query" and run this code from there


Ugo, thank you so much. I have the query running without error now.

The code is supposed to create a stored memory variable called "Sfirst".

I have the "GetFirst" code under the "First" button with the intent of putting the memory variable beside the button. The "Sfirst" should "Barbara" but it shows "Sfirst". See attached.

Hello @mdsmith1,

Sfirst is showing up here because it has been set as the default value.

This can be set dynamically with Javascript to the value in the localstorage e.g


We have just created an interactive section within our docs which I feel would greatly help you in building apps within retool

1 Like

Thank you so much for your reply. It works perfectly.
Thank you again.

1 Like

I got some issues too can you guys help me

The component help section is just excellent. It is very helpful.

Hello agaitan026

I have responded to your thread