Automatic Field updates during Bulk Update

I have a Bulk Update via Primary Key action that is triggered by Grid/Table edits.
that works fine, but I would also like it to edit 2 fields that are not part of the grid in the same table to keep track of last updated and by whom.

so for example, there is a ticket and I change a value in the grid. can I also update fields that I didn't manually change? somehow include those fields in the changesetarray? in SQL I think a cross join would get me close to what I am looking for so only necessary rows would include the updated fields.

I just had the epiphany of including and hiding those fields in the grid and updating them when a field changes, so that they are included in the ChangeSetArray but I am having trouble finding the correct sequence of actions to change those fields in the grid.

for example:
my ChangeSetArray currently looks like this:
[{"Job":"NewJobNo","RecordID":1},{"Job":"NewJobNo2","RecordID":2}]

and the automatic fields would look like this:
{"UserID":1, "DateTime":"3/6/2024"}

so the desired result would be:
[{"Job":"NewJobNo","RecordID":1,"UserID":1, "DateTime":"3/6/2024"},
{"Job":"NewJobNo2","RecordID":2,"UserID":1, "DateTime":"3/6/2024"}]

You should be able to do this action as part of a transformer where you take the different values and return the desired object as the result. Something like:

var changes = {{table.changeSetArray}}
var autofields {{yourAutoFieldComponent.data}}
return _.merge(changes, autofields)
1 Like

I figured it out with your help and a little googlefoo

var changes = {{table1.changesetArray}}
var autofields = {{JSON.parse('{"userID":'+UserID.value.toString()+',"DateTime":"'+ new Date().toLocaleString().replace(',','') +'"}')}}

changes.forEach((node) => _.merge(node, autofields));

return changes

Much Appreciated

2 Likes