Dot-walking and reference fields
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
Want to learn this properly?
Our live, instructor-led ServiceNow Training covers this hands-on, with real projects and a certification path.
Check your understanding
What does dot-walking follow?
- A. A database join defined in the dictionary
- B. The sys_id stored in a reference field
- C. A related list definition
- D. A domain path
Show answer
B. The sys_id stored in a reference field
Reference fields store sys_ids, and dot-walking resolves them.
Which method is best when you need many fields from one referenced record?
- A. getValue for each
- B. getRefRecord once
- C. addQuery
- D. getDisplayValue
Show answer
B. getRefRecord once
getRefRecord loads the referenced record once instead of per field.