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


I have a a JS Function that is executed on startup, then is executed in the onChange property of a Selector widget.
It seems that when the function is executed on startup everything is ok, and I have data in my data field, but when I trigger the onChange by changing the value of the selector, the data field does no update.
Is this the expected behaviour ?
Maybe I’m missing something ?

Edit: I’m sure my query is well executed as the data field of the query I execute in the function do update.
Edit2: I’m not using directly data of my query because I transform it before rendering in a simple form,

Hi! Can you share a screenshots of the widget property were you are binding the results of your function?

I think you are experiencing this bug here: [Bug]-[5196]:JSObject Async function response data is not set when the function is executed using widget event like button onClick · Issue #15056 · appsmithorg/appsmith · GitHub
As a workaround, you can use storeValue() to store the data returned by the function to Appsmith store, then consume it inside your widgets.

Hi Amelia, yes it looks like the same bug.
Thank you.
I will try with storeValue, but I have also troubles with the storeValue function due to the asynchrone nature of this function.
A function who is trigerred in my application store the value of the query parameters in my store with StoreValue but it’s not working as expected, even with a await.

initApp: () => {
		.then(() => {
			async () => {
				Object.keys(appsmith.URL.queryParams).includes("clientCode") === true ?  await storeValue("clientCode",appsmith.URL.queryParams.clientCode,false) :  await storeValue("clientCode",getAllClients.data.value[0].cr2b8_codeclient,false)

Please try to return the promise as explained in this doc. If you are not returning it, it might not work as expected.