OBLYTECH Logo
OBLYTECH Logo

ServiceNow History Table: Tracing Field Changes

The ServiceNow history table, sys_history_line, holds the field-level changes for records whose history has been viewed, but it is a short-lived working copy. The permanent record is the audit table, sys_audit. To find who changed a field and when, turn auditing on for the table, then read the change from the record’s History view.

Three tables, three jobs

Record change data in ServiceNow spreads across three tables, and confusing them can leave a trace empty.

The Audit table, sys_audit, is the complete and permanent record of changes to audited records. Administrators use it when they need to follow a record’s history for as long as the record matters. The History Set table, sys_history_set, only says which records from audited tables have history attached. The History table, sys_history_line, stores the changes to field values themselves.

Put plainly, sys_audit is the ledger, sys_history_set is the index card, and sys_history_line is the photocopy made for whoever asked to see the file.

Auditing has to be on before there is anything to trace

Both history tables are built from audit data, so a table that is not audited has nothing to feed them. Auditing is switched on per table, and doing so tracks creation, update and deletion of records in that table. Once a table is audited, all of its fields are tracked unless you say otherwise.

Two approaches exist for narrowing what gets tracked:

Approach What you do Suits
Exclusion listing Audit the table and exclude chosen fields with the no_audit attribute on those fields Tables where most fields matter
Inclusion listing Audit the table but only for fields you name Tables where a few fields matter

The em_alert table is a special case. It cannot be audited as a whole, so for em_alert you audit selected fields only, setting audit=true on both the table and those fields.

Parent and child tables are separate

Audit flags do not pass between parent and child tables. Auditing cmdb_ci covers configuration items stored in that base table only, and auditing cmdb_ci_computer covers computer records, including the fields they derive from cmdb_ci. Set auditing on the table that holds the record. If a trace for a server comes back with no history, check which table the record lives in before concluding that the change was not made.

What a change record contains

Each audit entry carries the record sys_id, the changed field, the old value, the new value, an update count for that record and field, the date and time, and the user who made the change. A change reason is included where one exists, and an internal checkpoint ID is included when the record has multiple versions.

How the audit table stores a change

Each audit entry records the sys_id of the record that changed, so filtering on that sys_id returns all the audited changes for that record.

Each audit entry records the user who made the change.

How history sets get created

The platform builds History Set and History records automatically from the Audit table. Generation happens when a user creates a record or asks for its history. The history data also includes the information that is set when the record is inserted, including journal entries. Journal entries created before the record are treated the same way and carry the record’s creation time and creator.

After a history set exists, the History choice in the form context menu reads from it instead of going back to audit records. People looking at the screen see the same kind of historical data either way. The system uses history set data for recent changes and audit data as the complete source.

Why the history table is the wrong place for long-range reporting

The two history tables are housekeeping tables. In the Zurich release:

  • The table cleaner deletes History Set records that have not been updated in 30 days.
  • History tables rotate among four tables every seven days.
  • The leading table is truncated at each rotation, so the longest a history line survives is 21 days.
  • Older history can be regenerated from audit records when someone asks for it.

That behaviour has a direct consequence for anyone building a report or a database view on sys_history_line. The rows disappear on a schedule, so a report built there will show gaps that are a product of rotation and not of missing changes. Older data comes from sys_audit directly, which becomes inefficient to query as it grows.

Reading history on a record

For a record on an audited table, open the form context menu and choose History, then List. The list shows each change as its own row. Auditing must be enabled for the table, or there is no list to open.

Role requirements matter here. The list option is limited to the admin role by default, and a user needs at least one role named in the glide.history.role property, which includes itil by default. To let non-admin users open the list, create a custom ACL that grants read on the Record History table, which is sys_history_set.

Field-level security applies on top of this. To change which roles may view record history, an administrator edits the comma-separated role list in glide.history.role under System Properties. If a user without read access to a field opens a record’s history, changes to that field are omitted from what they see.

The CI history timeline

Configuration items get an extra view. A timeline opens from a CI’s history and shows changes to the CI, its related records, relationships, baselines and proposed changes. Each change appears as a bubble, with the shape giving the type of change and the colour showing whether the change is valid. Baselines show as black circles.

The timeline needs the CI to sit in cmdb_ci or a descendant table, needs auditing enabled for those tables, and needs read access to the History Set table. The default view covers the last month, and the zoom runs from one minute up to the whole data period. A property filter hides bubbles where only unselected properties changed; changed properties inside the filter are highlighted in light blue. Summary view shows a snapshot for each bubble with the old and new values and any added or deleted relationships, and can list all properties or only the changed ones. Detail view shows read-only CI snapshots, and the next and previous buttons step through change sets in order.

A relationship change counts as valid on the timeline only when it was made through change management or the Proposed Changes framework.

What auditing leaves out

An investigation that depends on a change the platform never recorded will stall, so it helps to know the gaps. Auditing excludes:

  • updates made by upgrades
  • updates through import sets, and Import XML
  • applying update sets
  • fields with no_audit
  • fields prefixed sys_, apart from sys_class_name and sys_domain_id
  • updates from inactivity monitors
  • manual Performance Analytics score changes
  • some updates triggered by UI pages
  • records in parent or child tables not themselves audited

Deletions in the trace

Deletions have their own rules. Deleting from a form is audited unless the table carries the no_audit_delete attribute. List deletions are audited when the table is audited and is not in the glide.db.audit.ignore.delete property. Deletions made by script or scheduled job are audited by default. System tables do not audit deletions unless added to the glide.ui.audit_deleted_tables property list.

The ignore property is absent by default, and a default ignored list applies, covering tables such as sys_audit, wf_context and sc_cart. If you add the property yourself, your value replaces that default list, so copy over any default entries you still want ignored.

When audit records are written

In the Zurich release, audit records are created in the same transaction as the record change, not in a background thread, which cuts down on lost audit rows when a transaction is cancelled. The glide.db.audit.lazy property defaults to False. Setting it to True disables this enhanced process. Deleting the property, if it exists, restores the default.

A short field-trace routine

  1. Confirm the table is audited, and that the record is in the table you think it is.
  2. Confirm the field does not carry no_audit.
  3. Open History, List for the record, as an admin or a user with the access described above.
  4. Find the row for the field and read the old value, new value and user.
  5. For a change older than the history window, go to the audit table, filtered by table and record sys_id.

How can a buyer show that each production change record is complete, traceable and unaltered under OSFI B-13?

A buyer shows this by sampling production deployments and tracing each one back to a change record that holds the approval, the test result, the identity that ran the change and a post-change check. The buyer then confirms that the platform audit trail covers every route a production change can take, because that is where gaps usually hide.

Start from deployments and work back to the change record

Begin with the deployment log from the pipeline or release tool, not the change ticket. Pick a sample of production deployments and find the matching change record for each one. A deployment with no change record is the most important finding, because automated deployments can run without a ticket.

Check that each record holds the full lifecycle

Section 2.5 of B-13 expects each production technology change to pass through six stages: documented, assessed, tested, approved, implemented and verified. A record missing one of those steps is incomplete. For each sampled change, confirm the record links to:

  • the request and the configuration item it affects
  • the risk assessment or policy decision that routed it
  • test and security results, with the tester named
  • an approval by someone other than the person who deployed
  • the deployment artifact and the identity that executed it
  • the execution outcome and the post-change verification

Use the audit table for field-level proof

For evidence, pull the audit rows for each sampled record rather than the History view, because history lines are rotated out on a schedule. Then compare the user on each audit row with the approver named on the change record, and the audit timestamp with the deployment time from the pipeline.

Find the changes the audit trail never records

Upgrades, imports and applied update sets can all change production data without leaving an audit row, and so can a field excluded from auditing. Compare the audited table and field list with the routes production changes actually take. A change that arrives by update set or import is a gap unless a compensating control covers it.

Confirm the audit settings have not been quietly changed

Check the value of glide.db.audit.lazy on each production instance and compare it with the Zurich default of False. A value other than that default is a change to audit behavior, so ask who set it and when. Treat changes to these properties and audit flags as production changes needing their own approval.

What to request from the implementer

  1. The reconciled sample, with every unmatched deployment listed.
  2. The audited table and field list for production, including each no_audit field.
  3. The current value of glide.db.audit.lazy, dated.
  4. Evidence that approvers and deployers are separate people, because a workflow approval on its own does not show that the approver and the deployer were different people.

Frequently asked questions

Is the history table the same as the audit table?

No. sys_audit is the permanent record. sys_history_line holds field changes built from audit data and is cleared on a rotation.

How long does the history table keep data?

In the Zurich release, History Set records not updated in 30 days are deleted, and history lines are rotated across four tables every seven days, so a line lasts at most 21 days.

Why does a field change not show up in History?

The table may not be audited, the field may carry no_audit, or the change may have come through an import set, an update set or an upgrade, all of which auditing leaves out.

Who can open the history list?

Admins by default. Non-admin users need a custom ACL that grants read on the Record History table.