Manually updating changesetArray for bulk updates

I have a table with an editable column and I'd like to push bulk updates across multiple rows. I can't seem to find a way to set changesetArray with new values from a javascript query. Does anybody have an idea how to do this?

Hi Eric,

Are you trying something like this after a change?

Yes, sort of? I want to manually add new objects in bulk to the changesetArray. let's say I have a column called "activated". And let's say I have another data source that would allow me to update that column in the table and let the user preview it before applying the changeset.

I would want to say table1.changesetArray = newChangesetArray

I don't get it exactly, but in the query, you can use Object.assign()

const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };

const returnedTarget = Object.assign(target, source);

// Expected output: Object { a: 1, b: 4, c: 5 }

console.log(returnedTarget === target);
// Expected output: true

AFAIK, you cannot alter the changesetArray at all (there is no public set function for this property).

You would have to transform and return the whole set of data and use the results for your review table and then use that table to drive the bulk updates.

Yeah, this is what I suspected. There's no "set" function for the changesetArray. I guess I would have to write some kind of query or transformer to sit inbetween the database and the table. it would be nice to be able to update the changeset and then "save" those changes.

1 Like

I am with you. Updating the changeSet programmatically instead of updating the table source and reloading (which can be "expensive") has been requested a few times before but there is no clue if this has ever made it to the roadmap or not.
If a Retooler could chime in...

Hello @Eric_McGregor , @yiga2 ,

There is currently no way to update the changeSetArray programmatically built in Retool. I have gone ahead and created a Feature Request in our logs as I can see the value as well.



My use case is to give the user a preview

for example, i have a function that copies data from a table and user can paste it to another, so my idea is to set the copied data as a ChangesetArray, that way the user can preview the changes that will be made

I have a use case for this as well: I'd like to create a way to programatically fill a column with the last changed value in that column. I can not achieve this using a query since I'd need to dynamically set the column. Disabling prepared statements entirely for our RetoolDB instance is way too excessive to be able to support this one use-case.

P.s. off-topic but being able to disable prepared statements on the query level would be an even better solution.

"disable prepared statements on the query level"

Hey, I think you CAN do this. Go to your query resource under 'resources'. look at the settings. there's a checkbox for "Disable converting queries to prepared statements".

I'm fairly new to Retool, but from what I can see, "Resources" are thing like Database connections and API connections, right?

If I go to the code tab, find my query and look under "advanced", I don't see an option "Disable converting queries to prepared statements". I can only find that as a setting for my DB Connection, which would mean it wouldn't be on the query level, but rather on the db connection level, which is way to broad for us.

Please let me know if I'm missing something!

I also have a use case for this. I have a table which stores a backend value in Cents. In retool, I want to display it dollars and allow the user to edit the value as a retool Currency. Retool Currency does not play nice with the backend stored as cents, so I need to multiply the user value by 100 in order to save it to my database properly.