In a ServiceNow transform map, coalesce is the setting that tells the import how to recognize a row it has already loaded. Mark one or more fields as coalesce fields, and each incoming row is matched against existing records on those values. A match updates the record that already exists, and no match creates a new one. Leave coalesce off and each row becomes a new record, which is the usual reason a second run of the same file doubles your users or configuration items.
How a transform map coalesce setting handles each row
A transform map works through the import set one row at a time. For each row, the engine checks the target table. If coalesce fields are marked on the field map, it searches for an existing record whose values in those fields equal the incoming values. If it finds one, the mapped fields are written onto that record. If it finds none, a new record is inserted. When several fields are marked, the match needs every one of them to agree, so adding a second key narrows the match rather than widening it.
Running one import twice shows what coalesce changes
Take an illustrative file of three people with columns for employee number, email, first name and department. Mark employee number as the coalesce field on the user map, then run the import once. Three user records are created. Next, change one person’s department in the file, add one new person, and run the same file again.
On the second run, the two unchanged rows find their existing records by employee number and write the same values back, so nothing visible moves. The changed row finds its record and updates the department without creating anyone new. The new row finds no match and inserts one. The table ends with four users, one per person. Without the coalesce mark, the second run would insert all four rows again and leave you with seven users, three of them duplicates to clean up by hand.
Choosing a coalesce key that stays stable
The key has to identify the same real-world thing on each run. Good candidates are identifiers the source system issues and does not reuse: employee or badge numbers, hardware serial numbers, asset tags, or a stable external ID from the system that produced the file. Weak candidates are values that change or repeat. Display names change when someone corrects a spelling. Department and location repeat across many people, so matching on them merges unrelated records. Email addresses look unique, but they are only as reliable as the source that supplies them, so use them only where that source keeps them accurate.
Stopping duplicates on repeated imports
Duplicates on re-import usually come from one of three gaps. The first is that no coalesce field is set on the map, so each run inserts. The second is that the coalesce field is set but the source column holds blanks or stray spaces. By default a blank key does not match, so a row with an empty key is ignored or can overwrite an existing record. Blank rows insert as new records when the transform map’s Create new record on empty coalesce fields option is ticked, so a re-run adds those rows again. Capitalization does not block a match by default, because coalescing is case-insensitive unless the field map’s case-sensitive option is ticked. The third is that the key in the file is not the field the instance matches on, for example mapping an external ID to a field another process overwrites.
Before a large run, check that the key column has no blanks, trim whitespace, and agree on the format of codes that can lose leading zeros. Then load a small subset first, confirm the record counts, and only then run the full file. For the wider sequence of loading data into the platform, see the broader data migration and import sets guide, and for the order of cutover steps, the implementation roadmap for data migration and import sets lays out how the pieces fit together.
Transform scripts and the processing path
Coalesce decides which record a row lands on. The transform scripts decide what happens around that moment. The onStart script runs once before any rows are processed, which suits setup and lookups. onBefore runs for each row before it is written, which is where you can decide to skip a row or adjust values based on what the row contains. onAfter runs for each row after its record is written, which suits follow-up work tied to that specific record. onComplete runs once after the last row, which suits summary checks. Confirm the hooks and their order on your own instance before you build logic that depends on the sequence.
The platform also offers a second transformer type that is more flexible than a transform map. When a data source has both, the platform uses this second transformer instead of the transform map. Check the configuration on your own instance, then run a small canary file and watch which path writes the rows before you rely on either one.
Skipping rows and creating referenced records
Two things are often confused with coalesce. Skipping a row stops that row from being written, and it is normally handled in the before-row logic rather than by leaving a field blank. Foreign record insert is different. When a reference field points at a record that does not exist yet, the map can create that referenced record during the import, such as a location or a department, instead of leaving the reference empty. That helps on a first load, but on later runs a small change in the source spelling can quietly create a second referenced record. Decide on purpose which reference values are allowed to create records.
Frequently asked questions
What happens if coalesce is not set on a transform map?
Each row is inserted as a new record. That is correct for a one-off load of a clean, new table, but it causes duplicates on any run that repeats rows already in the target.
Can I coalesce on more than one field?
Yes. When several fields are marked, all of them must match for a row to update an existing record. Use a combination only when no single field is reliable, because each extra key makes a match less likely and can leave a true duplicate unmatched.
Does coalesce remove records that are missing from a newer file?
No. A coalesce match only updates or inserts. A person missing from the latest file keeps their existing record. Deactivating or removing records that disappear from the source is a separate process, and it needs its own design and testing.
Where should I start when a re-import creates duplicates?
Start with the field map. Confirm that coalesce is switched on and sits on the field that holds the stable key. Then check the source column for blanks, extra spaces and formatting differences. Once the data is loaded cleanly, the next question is what automation runs on those records. For that, see the overview of ServiceNow workflow automation.
Reconciling row counts after a re-import shows whether coalesce worked
A re-import is only finished when its counts reconcile. Each row in the source file should end in one clear outcome: a new record, an update to an existing record, or a row skipped by a before-row script. If those totals do not add up to the file’s row count, some rows went somewhere you did not plan for, and the table cannot yet be trusted.
Take the four-row file from the example above. On the second run the expected split is two unchanged rows, one update and one insert. Then compare the table with the file. Count the distinct employee numbers in the source, then count the user records that carry them. The two figures should match. If the table holds more records than distinct keys, one run created a second copy, and the usual cause is a key that was blank or written differently in that run.
| Outcome | Expected on the second run |
|---|---|
| Unchanged | 2 |
| Updated | 1 |
| Inserted | 1 |
| Skipped or failed | 0 |
| Total | 4, matching the file |
Start from the import history of the run, and check the error code on each failed row that has one. Read the reason on each one before you rerun anything. A rerun of a file with unresolved failures tends to repeat the same failures, and a rerun without coalesce set adds the good rows a second time.
Use the same check on a canary file before the full run. A subset that reconciles tells you the key, the field map and the skip logic agree with each other. A subset that does not reconcile narrows the fault to one of those three, and rerunning a small file costs far less than cleaning up a doubled table. Write the counts down for each run, so the next run has numbers to compare against rather than memory.
For a full cutover, the evidence a migration needs goes beyond one run’s counts, and it is covered on the page about data migration and cutover with reconciliation evidence. When duplicates come from the same thing being created in more than one place, the matching logic needs the same discipline as CMDB reconciliation and duplicate control.