ITIL 3.7.18 History of Change

History Function:
Every data object that can be manually changed has a record history of each and every field value changed.   For each field value change, the date, time and user is recorded.   Data is not lost because it is overtyped - the original field value is retained and can be restored.
History cannot be changed, but extra changes can be made to restore overtyped values.

History Logic:
History spread sheet is triggered from any change data entry form where a single record has been identified.   The primary key of the record is passed to the history 4GL function page - the 4GL provides an array of field numbers and names.   The primary record is read by key and stored as an array of values for each field.   The 4GL provides the foreign key number that secondary data is to be browsed to match - such as c04.   Secondary records are browsed in reverse date order - latest change is top of the list.   For each field, if the field value is changed, a history row is shown and the field value array is updated.
Arrays: Field name by field number, Field value by field number. Field type by field number.   Field type holds edit details to show dates, times and lists in decoded format.
History row: Row number (paged), Date, Time, User Name, Field Number, Field Name, Old Value, New Value, Restore button.

History Cookie:
History is like a spread sheet - it is controlled for each person using a local cookie.   The cookie holds paging number, number of rows per page and mode - indexed by web page number.   Paging simply skips data rows that are not part of the viewable window.
History reuses the spread sheet menu bar function and the menu bar cookie.

Primary and Secondary Tables:
Every data object is implemented as a primary and secondary pair of tables.   The primary table holds active current records.   The secondary table holds a copy of every record before any field value is changed.   The secondary table also holds a default field value record that is cloned by an "add" function.

Active and Inactive:
Data cannot be deleted, but it may be hidden by changing its state from "active" to "inactive".   When a record is changed to "inactive" it is physically moved to the secondary table and removed fromt he primary table.   Any "inactive" record can be restored as "active" by copying it back to the primary table.
The primary data spread sheet has an option to "delete" a record by changing its state to "inactive".   The act of moving the record from primary to secondary tables is undertaken by the DB field update function.
The secondary data spread sheet has an option to "restore" a record by changing its state to "active".   The act of moving the record from secondary to primary tables is undertaken by the DB field update function.