The key to reliable field auto-population is understanding when ServiceNow loads referenced record data. Dot-walking like current.assignment_group.manager triggers a single database query per unique reference, while getRefRecord() gives you a full GlideRecord object for complex logic. Most developers fail because they don't check for null references or handle the form refresh cycle properly — your Business Rule will fire again when the form reloads, creating infinite loops if you don't guard against unchanged values.

When to use this pattern

  • Auto-filling assignment fields when a group is selected on incidents or requests
  • Copying configuration data from a parent record to child records during creation
  • Setting default values based on user location, department, or role references
  • Inheriting approval rules or SLA conditions from referenced catalog items

When NOT to use this pattern

  • Don't use in client scripts — use GlideAjax to call a Script Include instead
  • Don't populate from calculated or aggregated data — use GlideAggregate in a Script Include
  • Don't use for real-time data that changes frequently — query it fresh when needed
  • Don't chain multiple reference lookups in one expression — performance degrades exponentially

Key behaviors and gotchas

  • Always check changes() on the source field to prevent infinite loops when the form refreshes
  • Use nil() not == '' for reference field checks — they handle null differently
  • Dot-walking queries the database immediately; getRefRecord() caches the full record for multiple field access
  • Before Business Rules run after ACL checks but before database constraints validation
  • Cross-scope reference lookups respect domain separation and may return empty for restricted records
  • Always validate isValidRecord() on getRefRecord() results — referenced records can be deleted or inaccessible
⚠️

Never populate reference fields with display values or names — only sys_ids. Setting current.assigned_to = 'John Smith' will create a new user record with that name as the user_name field.

Free Newsletter

Enjoying this? Get one deep-dive per week.

Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.

No spam · Unsubscribe anytime