Difference between getValue() and getDisplay()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 05:49 AM
Hi everyone,
I’m currently learning ServiceNow and got confused between the usage of getValue() and getDisplay() methods in scripts.
Can someone clearly explain:
What is the difference between getValue() and getDisplay()?
When should we use getValue() and getDisplay() ?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 05:54 AM
Hi @22eg105p57 ,
getValue() will retrive the value of the field - incase of reference field you will get the sys ID.
getDisplayValue() will retrive the display value of the field - incase of reference field you will get the Display value instead of sys ID.
Please mark as Accepted if this resolves your issue.
Regards,
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 06:01 AM
getValue()
- Returns the actual stored value in the database.
- For reference fields, it gives the sys_id.
- For date fields, it gives the raw date-time string.
Use when you need to work with the real data (e.g., for conditions, comparisons, or updates).
getDisplay()
- Returns the user-friendly display value.
- For reference fields, it gives the name or number (e.g., INC0012345 instead of a sys_id).
- For date fields, it gives the formatted date as seen on the form.
Use when you want to show something to the user or log readable info.
var assignedToValue = g_form.getValue('assigned_to'); // returns sys_id
var assignedToDisplay = g_form.getDisplayValue('assigned_to'); // returns name like "John Doe"
Sharing some of the Coomunity link as well FYR:
Need a simple and clear answer! - ServiceNow Community
How to use getDisplayValue() and getValue() for ... - ServiceNow Community
Difference between getDisplayBox(), getValue() and... - ServiceNow Community
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 06:08 AM
Hi @22eg105p57 ,
Hope you're doing well!
getValue() returns the raw stored value from the database i.e., actual/internal value of the field—ideal for scripting logic, comparisons, and record processing.
getDisplayValue() returns the user-facing label or formatted text i.e., label/display value of the field—what you'd actually see on the form.
Here are few examples based on field type:
1. Choice Field (e.g., Priority)
var pr = gr.getValue('priority'); // “1” (the stored value)
var prLabel = gr.getDisplayValue('priority'); // “High” (the display label)
Use getValue() when comparing e.g., if (pr == '1'), but use getDisplayValue() when you want to show "High" to a user in a message.
2. Reference Field (e.g., Caller)
var callerId = gr.getValue('caller_id');
// → sys_id like "46d44abc0a0a0a0a0a0a0a0a0a0a0a0a"
var callerName = gr.getDisplayValue('caller_id');
// → full name "Alice Johnson"
Use getValue() when linking or joining records; use getDisplayValue() for showing user-friendly names.
3. Date Fields
var d = gr.getValue('opened_at'); // "2025-07-06"
var disp = gr.getDisplayValue('opened_at'); // also "2025-07-06"
4. Date-Time Fields
var dt = gr.getValue('opened_at'); // "2025-07-06 14:30:00" (UTC storage)
var dtDisp = gr.getDisplayValue('opened_at'); // "2025-07-06 10:30:00" (user timezone)
getValue( ) is generally faster and lighter in terms of performance compared to getDisplayValue() because it directly retrieves the stored value without additional processing, but getDisplayValue() may involve additional processing to retrieve value.
Please refer to this article for more details & examples:
How to use getDisplayValue() and getValue() for ... - ServiceNow Community
Best Regards,
Sharif