Adding fields to Changeset

can anyone point me in the right direction on how to add in additional columns to the Changeset array or changeset object to successfully bulk update changes in my table? For example if there are 3 columns (primary key, number, string) and you edit the number, you'll get the primary key and number in the changeset, but I also need to pass back the string to the SQL database as it is is altered when the number gets edited via additional code that doesn't trigger a change.

What do I do in either the Array of records to update or transformer box on the update query to get that to happen for all rows that are edited?

1 Like

Hello @Stuart,

It returns the entire row even though I only changed the created at value...

{{ _.map(table1.changesetArray, (row) => _.merge(_.find(table1.data, { id: row.id }), row)) }}

I built a quick example to give you some ideas. Good luck!

I actually found a native way to do this. I didn't know this feature existed.

5 Likes

Wow, that would have been pretty easy if I found that!! I already got your other solution working though, but I guess I'll test that out as it'll be even less to maintain. Thanks so much!

@edurmush one caveat, the above checkbox returns table rows with mapped data (as displayed), not source table.data.

@Tess @Kabirdas or other Retooler, it would be nice to have an additional checkbox to indicate which full rows to return in the changeset, displayed vs source.

To be honest, that's exactly what I want, I do calculations on screen and need to return that to the database, the original solution returned blank cells where the calcs happen and I was going to start to figure out how to modify it to add in the calcs that happen on screen, but this checkbox makes that all go away!

@yiga2 doing some testing and there's actually ANOTHER caveat.... it shows the previous state of calculated data, not exactly as displayed.

For example I have a column that calculates a list price based on a discount % (in a tag column) when I change the discount tag to 50%, the list price goes from $1000 to $500 on screen, but the changeset array still shows $1000 in the changeset array (but shows the new 50% tag value) until I change something ELSE, at which point the changeset array gets the updated $500 value.

After some further testing, it appears the changeset gets the updated value of the edited field before the other columns have had a chance to evaluate their formulas, I can't figure out how to trigger the changeset to refresh again after a few hundred ms.

I will bring this up to office hours, but in case anyone reading this has any ideas before then... what could I do to trigger a hidden change in the background to get the changeset to refresh after the cell is changed?

Following up here post office hours, we don't currently have any methods for re-fetching the changeset :disappointed: The changeset will only update when a manual change is made to the table. We discussed possibly tracking the state of the table calculations and data using variables as a workaround.

Thank you Tess! Was a bit swamped with some other client projects but coming back around to this now. Really appreciate all of your help!

1 Like