clearChangeset() not working

when calling clearChangeset() in a JS Query, the changesetObject clears, but the changesetArray does not clear, it keeps its data, which causes problems down the line. Is anyone else having this issue? It would appear to be a bug and its preventing a critical business operation on my end.

Hi @Nick_Michniok, if you are accessing the value of the changeSetArray within the JS query (before or after clearing) there are a couple of extra steps we need for this to work.

First, we need to enable the following advanced setting for the query to keep real time values for our references:

Note: The default setting is off, for improved performance.

Then, ".clearChangeset()" is an async function. Adding "await" to it will run it synchronously. For example:

Without "await":

With "await":

Let us know if you have any questions! :slightly_smiling_face:

Thanks for the response. I checked that box in the Advanced section and also added await to my clearChangset() function, but it’s still not working as expected. In my JS query where I run the clearChangeset() function I am not accessing the changeSetArray value. When I trigger the query that has the clearChangeset() function, the changesetObject gets cleared, but the changesetArray does not. Is that how it is supposed to work? I've attached screenshots that show the changesetArray and changesetObject when they are populated, and then when I run the query, you can see that the changesetObject gets cleared, but the changesetArray does not.

That is odd, definitely not how it's supposed to work. I am unable to reproduce it on my end, after I run the JS query, both the "changesetArray" and "changesetObject" get cleared:

Could you share a screenshot of the JS query?

Here you go:

The data that is used to populate the table in question comes from the tableRValues variable that gets set on line 35

Interesting, looks good. Could you add two console logs for the "chansetArray" & "changesetObject" after the "await resRValues.clearChangeset()" (inside the if statement, after line 30)? Please share a screenshot of the log in the console. With the current issue, we expect to see "null" for the value of the changesetObject, and the changesetArray still populated with the changes made on the table.

Here is the screenshot of the log:

Thank you! Are you on Cloud Retool or Self-hosted? If Self-hosted, which release version are you using?

As a workaround, we could add a "Success" event handler to clear the "changesetArray" and object with the built-in action.


Did the workaround work for you?

No, even when running the clearChangeset or ClearSelection function through the event handler still only clears the changesetObject and leaves the changesetArray untouched.

I deleted the table and rebuilt it and its now working correctly.

I'm glad the bug went away with the new table, but I'm sorry you had to go through the process of rebuilding it.