The goal of this solution is to automatically add trace fields to all tables so the user can see who added the record or who made the last change. This solution adds these fields to a separate tab page on a form. This looks like this in the GUI:
You can choose at what moment you want the fields to be filled: During editing or after saving the record.
The solution consists of code for Dynamic Model (for adding the fields) and two Control Procedures (for filling the fields). Depending on the moment you want the fields to be filled (during editing or after saving), you can choose either for a control procedure for defaults or for a control procedure for triggers.
This code adds trace columns to every table.
The trace fields are:
If you add the tag 'no_trace' to a table, no trace columns will be added to that table. The trace column are automatically translated in ENG and NL.
Important: Make sure that the Generation order has a low number, e.g. 10. The columns must be generated before the generation of the program objects.
The code in this topic is created in the Software Factory 2020.2.
This control procedure fills the trace column with the current user and date through defaults.
This template fills the trace column with the current user and date.
This control procedure fills the trace column with the current user and date by the trigger. Insert triggers and update triggers have different templates.
This template fills the trace columns with the current user and date after an insert.
This template fills the update trace columns with the current user and date after an update. If the update trigger is nested in another trigger, the trace columns will not be updated.
In the attachment you will find the code of this solution.