Scripting
What is the difference between getValue() and getDisplayValue() in GlideRecord?
The question
What is the difference between getValue() and getDisplayValue() in GlideRecord? Why does this matter?
Why This Comes Up in Interviews
This is one of the most frequently asked questions in ServiceNow interviews at all levels. It tests whether you understand how ServiceNow stores data vs how it displays data — a critical distinction that causes real bugs.
The Core Difference
- getValue() — Returns the raw value stored in the database (internal value)
- getDisplayValue() — Returns the human-readable value shown to users
Where They Differ
var gr = new GlideRecord('incident');
gr.get('number', 'INC0010001');
// REFERENCE FIELDS (biggest difference)
gr.getValue('caller_id'); // '6816f79cc0a8016401c5a33be04be441' (sys_id)
gr.getDisplayValue('caller_id'); // 'John Smith' (display name)
// CHOICE FIELDS
gr.getValue('state'); // '1' (internal number)
gr.getDisplayValue('state'); // 'New' (label text)
gr.getValue('priority'); // '1' (internal number)
gr.getDisplayValue('priority'); // '1 - Critical' (label text)
// DATE/TIME FIELDS
gr.getValue('opened_at'); // '2026-03-15 14:30:00' (UTC, internal)
gr.getDisplayValue('opened_at'); // '2026-03-15 09:30:00' (user's timezone)
// STRING FIELDS (no difference)
gr.getValue('short_description'); // 'Server is down'
gr.getDisplayValue('short_description'); // 'Server is down'Why It Matters
- For comparisons, always use getValue():
// WRONG — display values can change with language settings if (gr.getDisplayValue('state') == 'New') { ... } // CORRECT — internal values are consistent if (gr.getValue('state') == '1') { ... } - For displaying to users, use getDisplayValue():
// For messages, emails, notifications: gs.info('Assigned to: ' + gr.getDisplayValue('assigned_to')); // Shows: 'Assigned to: Jane Doe' (not a sys_id) - For integrations, use getValue():
// External systems need consistent, language-independent values var payload = { state: gr.getValue('state'), // '1' — always the same assignee: gr.getValue('assigned_to') // sys_id — stable reference };
💡 Interview Tip
The follow-up trap: 'What does gr.caller_id return without using getValue or getDisplayValue?' Answer: it returns a GlideElement object — not a string. This object behaves unpredictably in comparisons. Always use getValue() or getDisplayValue() explicitly to avoid subtle bugs.