Goal
The goal of this solution is to automatically add trace fields for setting a record to inactive for all tables that has a active field so the user can see who set the record to inactive. Since the records can have have additional changes to the records after setting them to inactive there are separate trace fields for this action. This looks like this in the GUI:
Solution
The solution consists of code for Dynamic Model (for adding the fields, for adding a prefilter to show only active records and add a task to deactivate active records and a task to activate inactive records.
Dynamic model add_active_inactive_fields
This code adds inactive trace columns to every table.
The trace fields are:
-
inactive_by
-
inactive_on
-
inactive_reason
These fields are added to every table that has a active column and doesn't have these inactive trace columns. The columns will be postioned just before the trace colums in a seperate form group.
Dynamic model prefilter_active
This code adds a prefilter active to every table that has a active column. The prefilter is default on unless a tab tag default_active_prefilter_off is added to the tab.
Dynamic model de_activate_task
This dynamic model code adds an activate task and a deactivate task to every table that has a active column and a tab tag deactivate_master_table. The column active is set to read only. This is done so the task can be authorised separately. The parameters of the task are primary key field(s) of the table and the inactivity reason. The tasks are automatically translated and added to the authorisation structure.
Control procedure context_activate_deactivate
This control procedure adds the template to shows or hides the (de)activate task based on the activity status of the record for tables with an active column. Use context is set to true for these tables
Template context_activate_deactivate
This templates hides the deactivate task for inactive records. The activate task is hidden for active records.
Control procedure task_activate
This control procedure adds the template to tables with an active column.
Template task_activate
This templates sets the inactive record to active.
Control procedure task_deactivate
This control procedure adds the template to tables with an active column.
Template task_deactivate
This templates sets the active record to deactive.