All of the row data with table updates

With the new table component I'm trying to get all of the fields in the updated rows of a table to write back to my db. This used to be possible with recordUpdates on the legacy table, but I can't figure out how to get this with the new table. I see my field changes in changesetArray or changesetObject, but I need all (or most) of the fields from the rows that were changed (not just the 1 changed field in that row). I'm assuming I just need some JS manipulation to filter down my table.data to the changed rows to get the additional fields, but my JS is terrible.

This was my transformer with the legacy table. How do I use changesetArray to get similar results?

let today = {{moment().format()}}
let username = {{current_user.fullName}} 

// The manually changed rules
let rule_updates = {{ rule_table.recordUpdates.map(row => _.pick(row, ["rule_id", "clinically_valid", "notes", "suggested_action"]) ) }}
  
rule_updates.forEach(record => {
    Object.assign(record, {"validator": username, "validation_dtm": today})
}) 

return rule_updates

Hello, if you want to include full row in all your changesetArray, you should check this box.

You code should be something like this

let today = {{moment().format()}}
let username = {{current_user.fullName}} 

// The manually changed rules
let rule_updates = {{ rule_table.changesetArray.map(row => _.pick(row, ["rule_id", "clinically_valid", "notes", "suggested_action"]) ) }}
  
rule_updates.forEach(record => {
    Object.assign(record, {"validator": username, "validation_dtm": today})
}) 

return rule_updates

Ha :joy: thanks! It never occurred to me that there might be a GUI checkbox for this!

1 Like