// 13 October 2026 · 5 min read
Transform maps that never overwrite good data with nulls
Six transform map patterns for coalescing, null guards, reference resolution, validation and idempotent imports.
By Acronite ServiceNow Practice
A transform map has one job: move data from an import set into a target table without making the target worse. In practice, many transform maps quietly do the opposite. A source system sends an empty field, the transform copies it, and a carefully maintained value disappears. Nobody notices until an incident is routed to a group that no longer exists, or an asset loses its cost centre the day before an audit.
This article covers the patterns we use so that transform maps never overwrite good data with nulls, never create duplicates, and leave an audit trail you can actually use.
Why nulls get through
By default, a field map copies whatever is in the source column, including empty strings. The checkbox "Copy empty fields" on the transform map controls this at the map level, but it is a blunt instrument: it is all or nothing, and teams often enable it to clear values that genuinely should be blanked, then forget it applies everywhere.
There are three distinct situations, and each needs a deliberate decision:
- Source is empty because it does not know. The most common case. The target value should be preserved.
- Source is empty because the value was removed. Rare, and usually better handled by an explicit "clear" marker.
- Source omits the column entirely. A partial feed. The field should not be touched at all.
A safe transform treats all three differently, and the default behaviour treats them the same.
Pattern 1: coalesce on stable identifiers
Before worrying about field values, make sure the transform updates the right record. Coalesce fields determine whether a row updates an existing record or inserts a new one. Coalescing on a display name is the root cause of most duplicate records we remediate.
Rules we follow:
- Coalesce on the most stable identifier the source can guarantee: serial number for hardware, employee number for users, a source system ID stored in a dedicated correlation field for everything else.
- When multiple fields must match, use a coalesce script that normalises them first. Serial numbers arrive with leading zeros, trailing spaces and mixed case. Normalise both sides before comparing.
- For configuration items, do not coalesce at all in the transform map. Route the data through the Identification and Reconciliation Engine, which applies class-aware identification rules and data source precedence.
Pattern 2: field-level null guards
Instead of relying on the map-level checkbox, guard each sensitive field. In an onBefore transform script we compare incoming values with the target and skip empty ones explicitly. The logic, in plain terms:
for each protected field:
if the source value is empty or whitespace:
keep the target's current value
else if the source value equals the target value:
skip (avoids needless audit noise)
else:
apply the source value
We keep the list of protected fields in a system property or a small configuration table, not hard-coded in the script, so data owners can extend it without a code change. Fields like support group, owner, cost centre, location and assignment group are always on the list.
When a source genuinely needs to clear a value, we agree an explicit sentinel such as CLEAR with the source team. The transform recognises it and blanks the field. Clearing becomes intentional and visible, not a side effect of a missing column.
Pattern 3: reference fields that resolve or reject
Reference fields are where silent damage hides. If the source sends a group name that does not match exactly, the default behaviour may create a new empty group record, or leave the reference empty. Both are bad.
We set "Choice action" and reference behaviour to reject unknown values rather than create them, and we resolve references through a lookup script that tries the sys_id, then a correlation ID, then a normalised name. Unresolved references are logged with the import row number so the source team can fix them, and the existing target value is preserved.
Pattern 4: validate before you write
Some rows should never reach the target at all. An onBefore script can set ignore = true for rows that fail validation: an asset with no serial, a user with a malformed email, a date in the future where the past is required. Each ignored row writes a message to the import log with a reason code.
We treat the ratio of ignored rows as a health metric for the integration. A sudden jump means the source changed format, and we would rather stop and investigate than write bad data quickly.
Pattern 5: make it idempotent
Running the same import twice must produce the same result as running it once. That sounds obvious, but scripts that append to journal fields, increment counters or create related records on every run break it. We design every transform so that a re-run is safe, which matters enormously when a large load fails halfway and must be resumed.
For related records, such as linking an asset to its CI, the script checks whether the relationship already exists before creating it. In one remediation we reconciled roughly 50,000 assets by serial number and IP address, repaired asset-to-CI links and ran the load multiple times during testing. Because every operation was idempotent and null-safe, not a single attribute was overwritten with a null.
Pattern 6: performance at volume
Transform scripts run per row. A script that issues three GlideRecord queries per row turns a 50,000-row load into 150,000 queries. We cache lookups in an onStart script, load reference data into memory once, and avoid getDisplayValue calls inside loops. For very large loads we split the import into scheduled chunks rather than one enormous run.
Testing transforms properly
Transform maps deserve the same test discipline as application code:
- Build a fixture import file with the edge cases: empty fields, whitespace-only values, unknown references, duplicate identifiers, the clear sentinel.
- Assert outcomes with Automated Test Framework steps that check target records after the import runs.
- Re-run the fixture to prove idempotency.
- Keep the fixture in source control with the scoped application that owns the integration.
The checklist
Before any transform map goes to production we confirm:
- Coalesce is on a stable, normalised identifier, or CIs route through IRE.
- Protected fields have null guards; clearing requires an explicit sentinel.
- Unknown references are rejected and logged, never auto-created.
- Validation rules skip bad rows with reason codes.
- Re-running the import produces no changes.
- Lookups are cached and the load has been timed at production volume.
A transform map built this way is boring in the best sense. It runs every night, the data improves a little each time, and nobody has to think about it.