How to store (and add to) an array in storeValue()?

Hi Appsmith team,

I’m experiencing some unexpected behavior, though it’s not clear to me whether this is an Appsmith problem or a JS misunderstanding on my part. I’m trying create an array of integers and store it in

Creation of the array looks like what I expect:
Screen Shot 2022-08-11 at 11.43.38 AM

The first .push addition also looks like what I expect:
Screen Shot 2022-08-11 at 11.45.13 AM

However, trying to push another value pushes into an empty array:
Screen Shot 2022-08-11 at 11.44.35 AM

I initially thought that I was overwriting the previous value, however, calling after pushing ‘2’ returns an empty array:
Screen Shot 2022-08-11 at 11.45.29 AM

My ultimate goal is to create a list of ids that I can add to and remove from, but I’m clearly missing doing something wrong or misunderstanding array storage. Thank you for any advice you can offer!


Hi Dan,
StoreValue is an async function, so you would need to use the await keyword. Then, to add an element to an array in Appsmith store, this is the way to do it:
Or a more simple implementation would be this:

Excellent; this totally got me up and running and I see what I was doing incorrectly. Apparently it’s because I understand NEITHER JS nor Appsmith as well as I should (not just one or the other!). Thank you for your help, Amelia!

One more issue I’m having here: I want to reset my stored variable once data is passed into my database via a query. However, it appears that having used this variable in the past affects its current use. I understand from the documentation that storeValue(‘myVar’,undefined) should clear the variable. However, I think the tests below show that’s not happening. Note that I see the same behavior with and without the false flag indicating a persistent vs. session variable. What’s happening here?

Screen Shot 2022-08-17 at 9.37.45 AM

Screen Shot 2022-08-17 at 9.31.37 AM

Have you stored a variable with the same name in the session store? If yes, then when returning, it will show the variable from the session store, not the one from the persistent store. To clear the variable from the session store and use the one from the persistent store, refresh the page.
Please also check this sample app that demonstrates the difference between persistent store and session store. Here is also the explainer video.

I hadn’t realized that Appsmith by default checks the session store first and returns that value!. Thank you! Now that I know what I’m looking for, I realized I missed this important line in the documentation:

This was far more of a hurdle than it should have been for me; I very much appreciate your guidance, Amelia!