HolySN

Comparing records

Two records, the same record on two instances, and the line diff that replaces the platform's own compare panel.

Three different questions, three tools, one comparison engine underneath.

Two records that are not the same record

/diff1 marks the record you are on as the left side, /diff2 marks the right side and runs the comparison. /diff1 - and /diff2 - forget a side.

The slots are stored rather than held in memory, because marking the first record and then going to the second is a page load. Typing /diff shows what is in each slot, named where the record had a name and by sys_id where it did not, so you are never comparing against something you forgot you marked.

The same record on two instances

/diffenv <instance> reads this record here and there, and lists every field that differs.

dev12345, dev12345.service-now.com and a full URL to a page on it all mean the same machine. The scheme is stripped before the trailing slash, in that order: doing it the other way round turned https:// into https: and produced a plausible-looking hostname that resolved to nothing, which a test caught.

How the other instance is reached is the part worth knowing. The comparison asks the extension to authenticate the request, and the extension picks the credential that belongs to the instance being called. The comparison never names a host to authenticate as, never sees a password, and cannot aim one customer's credentials at another customer's instance.

What is not compared

A named list, not a prefix match: created and updated by and on, the modification count, tags, and the domain columns. sys_scope and sys_name are deliberately still compared, because a record in the wrong scope or under a different name is a real difference.

A field present on one side only counts as a difference rather than being skipped.

The line diff

ServiceNow's own version-compare panel puts a whole multi-line script in one cell beside another whole script, and leaves you to find the changed line yourself.

A content script rewrites those rows into a unified line diff. It does not call into the panel: the panel is rendered by code this extension does not modify, so the hook is the DOM it produces. The worst case of a change on that side is that rows stop being upgraded, not that anything breaks.

A value is worth a line diff from two lines up, a single-line value over 120 characters gets a word diff, and three unchanged lines are kept around each change with the rest folded behind a count you can expand. The header says how many lines were added and removed.

The algorithm is Myers over hashed lines, with the common head and tail trimmed first, and a ceiling: past 600 edits or 20,000 lines it degrades to "replaced" rather than freezing the frame. The same implementation draws the alignment check's diffs, so the two screens cannot drift apart.

/versions opens the platform's own history for the record you are on, which is where those rows come from.

Comparing records | HolySN