Question
The table has 5 fields and I need to find out who was the last user to edit any of these fields.
Answer
A technical field is created in which a list of values from all 5 fields is generated&
Code in the technical field:
=: listCreate(item: #field_1; item: #field_2; item: #field_3; item: #field_4; item: #field_5)
Thus, when any of these fields are changed, the value in the technical field will be updated, and we can add action code to it that will record the user number in another field.
Action code in the technical field with the trigger On change:
=: set(table: $#ntn; field: 'log_user_field' = $#nu; where: 'id' = #id; log: true)
In this way, the log_user_field will always contain information about the user who made the last change in any of the 5 fields, and a log with the time of change will also be available.
Set action code with a trigger on change in each of the 5 fields:
=: set(table: $#ntn; field: 'log_user_field' = $#nu; where: 'id' = #id; log: "Changed Field 1")