IT CanvassTalk to an advisor
Data model · LessonBy , ServiceNow Trainer, 9 yrs · Published · ServiceNow · all levels

Dot-walking and reference fields

Reach fields on related records in filters, reports, scripts and notifications without writing joins.

Quick answer

Reach fields on related records in filters, reports, scripts and notifications without writing joins.

Key takeaways
  • Dot-walking works in filters, reports, notifications and script
  • Each hop is a query, so avoid it inside large loops
  • Use getRefRecord to read several fields from one referenced record
  • Convert GlideElement values before comparing them

What dot-walking is

A reference field stores the sys_id of another record. Dot-walking follows that pointer to read fields on the referenced record, in the condition builder and in script, using a dot between field names.

In script

GlideRecord returns GlideElement objects, so dot-walk then call getValue or toString to get a primitive.

var gr = new GlideRecord('incident');
gr.get('number', 'INC0010023');
gs.info(gr.caller_id.department.name.toString());
// safer for comparison
if (gr.caller_id.vip.toString() === 'true') { /* ... */ }

Costs and limits

Each dot-walk is another query behind the scenes.

  • Dot-walking in a list column is fine, dot-walking in a loop over ten thousand rows is not
  • You can dot-walk through several hops but readability drops fast
  • Document fields do not dot-walk, they need the document table plus sys_id
  • Use getRefRecord when you need many fields from the same referenced record

Practice challenge

+0 XPStreak ×0
Question 1 of 2
What does dot-walking follow?

Frequently asked questions

Why does my comparison fail even though the values look equal?
You are comparing a GlideElement object to a string. Call toString or getValue first.
Can I dot-walk in a notification?
Yes. The same syntax works in email templates, which is how you pull the caller department into a message.
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support