New table changesetArray does not work for me


not sure what I am doing wrong here, my table has a primary key called key, I make an update on my table column but the changesetArray is always empty.


Try {{table2.recordUpdates}}

I am afraid that does not work anymore with the new table structure, well so it seems


Looks like table2.changesetObject could work?

yes I get a result when I do that but then he is complaining it should be an array :slight_smile:

Working on it.... very weird

Hi @Sander!

Have you configured the "Primary key" column property in Table? When generating columns Table will do its best to guess your primary key column, but the logic is far from perfect.

If you have this property configured and you're still having issues with changesetArray please let us know!

I am seeing the same issue when attempting to edit a column...
Basically I am building out a table that may or may not contain the primary key as it doesn't exist yet (For example, I am gathering data within a data range and so some of the data may exist for let's say yesterday... but no data will exist for today, but I want to add hours for today... when using Bulk Upsert, I cannot edit any rows in the table without the Primary Key already being set.... which doesn't make sense because it is NOT there yet until I run the bulk upsert.
April 30 in screenshot below cannot be edited.....

All of this works perfectly in the older table component using recordUpdates.....

Screenshot 2023-05-05 at 11.14.10 AM

Hi @ScottR!

Yes, the functionality you're describing is missing in the new Table component, but it's dangerous to let end-users configure primary keys without validation to assert they're unique. Table gets confused if the primary keys are dynamic because it leverages the uniqueness to power more robust row selection and cell editing behavior. We can consider allowing the primary key column to be editable, but it's a bit of an anti-pattern and would have unintended side-effects.

For your use case I would recommend using changesetObject and adding a transformer to convert it into an array for your bulk update. In that transformer you would be able to assign missing primary keys, ensure they're unique, and deliver a better experience for your end users.

Does that seem like a reasonable solution?

Not really. This is because the primary key is generated when the row is added to the db - hence the UPSERT
If I don't set the Primary Key in the table component AND select the primary key in the Bulk Upsert query the changesetArray is empty....
Screenshot 2023-05-05 at 11.54.40 AM

but the changesetObject is populated but not correct...

When editing in an older table component, using recordUpdates, I get the entire row of data as I need it and am able to UPSERT....
Screenshot 2023-05-05 at 11.42.33 AM

1 Like

i see -- so sometimes the rows have a primary key, and sometimes they don't?

if it's just insertion i believe you can do Object.values(table1.changesetObject) to get the row changesets as an array, but they won't contain primary keys.

for both updates and insertions you can still achieve this behavior with a transformer that adds corresponding primary keys to rows that have been updated, but i agree this isn't ideal. i'll bring it up with the team and see what APIs we can add to make it easier! thank you for the detailed explanation.

great stuff, it was indeed the missing key on the table itself :joy:

thanks a lot

I'm having problems as well when trying to update. I have the primary key in my table control (the new Table version), and I have a Save Actions Add-On set up which calls my update query. The problem is, in the update query it doesn't accept table4.changesetArray or table4.changesetObject. The latter generates an error that it is not an array (literally "Data must be an array."). Several references for the new table component say to use changesetObject but no example of how to make this into an array is provided. Using the legacy table component and recordUpdates worked with no issues. Thanks for any help you can provide!

Hey @MikeFromMaine, thanks for adding your feedback here!

Would you mind sharing a screenshot of the error you're seeing when using changesetArray along with what it's evaluating to? Also curious to know if refreshing helps things at all.