Category: Appsmith Support


This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

“data” propery of a JS Object function is not updated after execution


I am having trouble with a JavaScript function that is executed on startup and on the onChange property of a Selector widget. The data field does not update when the function is triggered by changing the value of the selector. I have confirmed that the query is executed correctly and the data field updates on startup. It seems like a bug, which I found a workaround for using storeValue(), but I am also experiencing issues with it due to the asynchronous nature of the function.


The user is experiencing a bug where a JS function executed on startup updates a data field, but when triggered by an onChange event of a Selector widget, the data field does not update. This is a known bug in Appsmith, and a workaround is to use storeValue() to store the data returned by the function to the Appsmith store and consume it inside widgets. However, the user is also experiencing issues with storeValue() due to its asynchronous nature. The solution is to return the promise when calling the storeValue() function to ensure proper execution.

Here is an example of code that properly stores the value in the Appsmith store using storeValue():

initApp: () => { => {        const clientCode = Object.keys(appsmith.URL.queryParams).includes("clientCode") ? appsmith.URL.queryParams.clientCode :[0].cr2b8_codeclient;        return storeValue("clientCode", clientCode, false);    }).then(() => {{clientCode:})    });}