Transform scripts execute once per import row and bridge the gap between raw CSV data and ServiceNow records. The platform provides source and target objects that map to your import columns and target table fields. Most developers miss that transform scripts run in a separate execution context from business rules — they execute before the record exists in the target table, which means you can't rely on business rules to clean up bad data or set defaults. Setting ignore = true completely skips that row and prevents any record creation, which is your only chance to filter out junk data before it hits your target table.
When to use this
- When importing data that needs reference field lookups (user imports with department codes, CI imports with location names)
- When source data needs validation or conditional filtering before record creation
- When you need to normalize inconsistent source data formats (Yes/No to boolean, mixed case strings)
- When source column names don't match target field names and simple field mapping isn't enough
When NOT to use this
- Don't use transform scripts for simple one-to-one field mapping — use the field map tab instead
- Don't put business logic here that belongs in business rules — transform scripts can't be easily tested or reused
- Don't use this for large imports with complex lookups — consider preprocessing the data or using Import Set REST API instead
- Don't query the same reference table repeatedly — cache the results in a global object if you're doing the same lookup for every row
Key behaviors and gotchas
- Source values are always strings —
source.active == '0'notsource.active == 0, and empty cells become empty strings, not null - Setting
ignore = truemarks the import set row as ignored and prevents any target record creation or update - Transform scripts execute with elevated privileges — ACLs don't apply to your GlideRecord queries
- Reference field assignments require sys_ids — you must query the target table and extract
sys_idvalues, not display values - Failed lookups should log warnings but not fail the entire import — set empty strings for missing reference values
- Transform scripts run before duplicate detection — if you're doing coalesce imports, the script runs even for records that won't be inserted
Never assume source fields exist or have values. Empty CSV cells become empty strings in source fields, and missing columns throw undefined errors that will break your entire import batch.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.