How to get column name of changed cell

hi,

i need help to get the name of column, which i am manipulating. is it possible to get it?
you can see related area in the pic.

i need that key, not value.

Can you use the lodash keys method?

_.keys(changesetObject[1])
'{{table1.changesetArray[0].keys(changesetObject[1])}}'

that does not work.

i can get it but staticly like

'{{table1.selectedCell.columnId}}'

i am trying to catch the changes and push it into my audit table. like

INSERT INTO mr_audit_log_retool (entity_id, table_name, field_name, previous_value, new_value)
VALUES
  ('{{table1.changesetArray[0].buchungId}}', '{{mr_bookings.id}}', '{{table1.selectedCell.columnId}}'
, '{{table1.selectedCell.value}}', '{{table1.changesetObject[1].buchungEnde}}');

but there are some handicaps. that does not have a dynamic structure

  1. there is no loop to get all changes from changesetArray
  2. column name (field_name), previous value and new value are catched staticly.

That isn't how to use the lodash function though:

I think when you get the right column name out of the changesetArray with

_.keys(table1.changesetArray[0])

you'll get more traction with the SQL statement.
(eta: fixed the missing [0] in the changesetArray)

2 Likes

I also wanted to add an example of the loop you can use for the changesetArray:

This way you can make sure to grab all the changes from any column that require further processing

many thanks @pyrrho

A post was split to a new topic: Looping through table changes and triggering a SQL query