Skip to content

sc-audit-table

sc-audit-table-field-Example-1-Image-3

1 Purpose

sc-audit-table places an audit table on a form allowing the user to view the history of the current document.

The audit table displays a row for each saved version of a document.

The first audit table row shows who created the first version of the document and when. Each subsequent saved version of the document will result in another audit table entry.

The audit table rows will show:

  • Who made the change.
  • When the change was made.
  • The value of each changed field before the change.
  • The value of each changed field after the change.

The contents of the audit table are determined from the current and previous versions of the document and as such are not saved as part of the current document.

The sc-audit-table definition provides fields for setting the properties of a audit table field and is fully described below.

 

2 Definition

sc-audit-table is defined by a set of name/value pair fields consisting of:

  • Required system fields
  • Required customizable fields
  • Optional customizable fields

Note:

  1. Default values for fields described in the tables below are shown in bold text.

2.1 Required System Fields

Field Valid Values Description
componentName sc-audit-table The component name.
Example: "componentName": "sc-audit-table"

2.2 Required Customizable Fields

Field Valid Values Description
name Any value written in camel case. Defines the name of the text box field in the document and database.
Example: "name": "testScAuditTable"

2.3 Optional Customizable Fields

Field Valid Values Description
fullWidth true The audit table field displays full width on the form.
Example: "fullWidth": true
false Default value. The audit table field does not display full width on the form.
label Any value Defines the name of the audit table field on the form i.e. the field label.
Example: "label": "Test sc-audit-table"
Defaults to the audit table field displays without a field label on the form.
visible false The audit table field is not visible on the form.
Example: "visible": false
true Default value. The audit table field is visible on the form.
useLabels true The audit table will display the label of the field that has changed instead of the name. If the label is blank, the name is displayed
Example: "useLabels": true
false Default value. The audit table field displays field names.

 

3 Viewing Document History

The options for viewing the history of a document are:

Option 1:

Include a sc-audit-table field on the document template, resulting in each saved document displaying its audit history.

The downsides of this approach are:

  • An sc-audit-table would need to be added to each document template that has a document history requirement.
  • The document history would always display rather than viewing it on an as needed basis.

Use the audit table override template to display the history of the current document in a new tab. The browser shortcut script for audit table override template is:

javascript:(function()%7Bf=window.location.href+'/c387a030-7020-11e8-bd32-ffef5410d975'; if(!window.open(f)) location.href=f; %7D )()

The advantages of this approach are:

  • An sc-audit-table does not need to be added to each document template that has a document history requirement.
  • The document history can be viewed on an as needed basis.

 

4 Typical sc-audit-table Definition

Below is a typical sc-audit-table definition, defined with its required fields plus any optional field whose value is typically other than its default value.

        {
            "componentName": "sc-audit-table",
            "label": "Audit History of Document ",
            "name": "documentAuditHistory",
            "fullWidth": true
        }

One or more of the optional fields shown below can be included in the above definition should a value other than their default value be required.

            "visible": false,
            "useLabels":true

 

5 Examples

Example 1

A sc-audit-table definition defined with the typically needed fields.

        {
            "componentName": "sc-audit-table",
            "label": "Audit History of Document ",
            "name": "documentAuditHistory",
            "fullWidth": true
        }

Resulting field on the form prior to the creation of a document
This form has 5 fields plus the audit table. The audit table below the 5 fields will record the creation of a document and the history of changes to the 5 fields.

sc-audit-table-field-Example-1-Image-1

Resulting field on the form after creating and saving a document:

sc-audit-table-field-Example-1-Image-2

Resulting field on the form after updating and saving a document:

sc-audit-table-field-Example-1-Image-3