What It Does
The getDisplayValue() method retrieves the human-readable representation of a field's value, not the raw database value. This distinction becomes crucial when working with reference fields and choice lists, where the stored value differs significantly from what users see on screen.
Internally, ServiceNow performs a lookup operation when this method executes. For reference fields, it queries the referenced table to retrieve the display value of the referenced record. For choice fields, it accesses the choice list configuration to return the label corresponding to the stored choice value. The platform caches these lookups within the current session to improve performance.
The method returns a string containing the display value, or an empty string when the field is empty, doesn't exist, or the referenced record cannot be accessed due to ACL restrictions. Unlike getValue(), it never returns null - empty values consistently return empty strings.
Edge cases include mandatory reference fields without values (returns empty string), reference fields pointing to deleted records (returns empty string), and choice fields with custom values not in the choice list (returns the raw value). The method also handles dot-walked fields inconsistently - some dot-walked reference fields work while others return unexpected results.
This method pairs with getValue() and getReference() in the GlideForm arsenal. While getValue() returns sys_ids and choice values, and getReference() returns GlideElementReference objects, getDisplayValue() provides the user-friendly labels ideal for display purposes.
When to Use This
Use getDisplayValue() when building user-facing messages, populating read-only fields with human-readable content, or performing client-side validation that needs to reference what the user actually sees. It's essential for creating meaningful alert messages, confirmation dialogs, and field labels that make sense to end users rather than displaying cryptic sys_ids or choice values.
Avoid this method when you need the actual database value for queries, comparisons, or server-side operations. Use getValue() instead for programmatic operations, and use getReference() when you need to access additional fields from referenced records. Don't use getDisplayValue() for string fields, date fields, or numeric fields where the display value matches the stored value - it's unnecessary overhead.
Common misuse includes trying to set field values using display values (which fails), using display values in database queries server-side (they won't match), and assuming the display value will always match what you see in lists or forms (ACLs and personalization can alter display behavior).
Return Value
Returns a string containing the display representation of the field's value. For reference fields, this is the display value from the referenced record (typically the name field). For choice fields, this is the choice label as defined in the choice list. For other field types, the return value typically matches what getValue() would return, formatted according to the user's locale and preferences.
When the field is empty, the field doesn't exist, or access is denied, the method returns an empty string rather than null or undefined. This makes it safe to use in string concatenation and display operations without additional null checking, though you should still validate for meaningful content when the distinction between empty and missing matters.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Platform Behavior & Side Effects
- No Business Rules, notifications, or audit records are triggered by reading display values
- ACLs are respected - if you can't read the referenced record, you get an empty string
- Database queries may execute for reference field lookups, impacting performance on forms with many reference fields
- Display values are cached within the current client session to avoid repeated lookups
- Choice field translations are applied based on the user's current language preference
- No database writes occur - this is a purely read operation that doesn't modify any records
- Field security and encryption are bypassed for display purposes, but ACLs still apply to the underlying record access