- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 05:53 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 setDisplayValue()?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 06:53 AM
Hi @22eg105p57 ,
getDisplayValue() is used to retrieve the displayed (user-friendly) value of a field. For example, if you're working with a reference field like "assigned_to", this method will return the user's name.
getValue(), on the other hand, retrieves the actual stored value in the database, which may differ from the display value. For reference fields, it typically returns the Sys ID or a unique value.
setDisplayValue() method sets the value of a reference field by using its display value (e.g., a user's name instead of their sys_id).
For Better understanding please go through: How to use getDisplayValue() and getValue() for ... - ServiceNow Community
If my response solves your query, please marked helpful by selecting Accept as Solution and Helpful. Let me know if anything else is required.
Thanks,
Prerna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 05:58 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:03 AM
@22eg105p57 Can you refer this Difference between getValue() and getDisplay() - ServiceNow Community .. Just responded
✔️ 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:06 AM - edited 07-07-2025 06:07 AM
Hello @22eg105p57
getValue() = Returns the raw value stored in the database. Typically used for fields like reference, choice, date/time, etc.
ex
var user = gr.getValue('assigned_to'); // returns sys_id
getDisplayValue() = Returns the human-readable display value of a field. Especially useful for reference or choice fields.
ex.
var userName = gr.getDisplayValue('assigned_to'); // returns name like "John Doe"
setDisplayValue() (used in GlideRecord scripting) = Sets the display value for a field, typically used when inserting or updating reference/choice fields. ServiceNow will resolve the display value to the actual value (e.g., sys_id) behind the scenes.
ex.
gr.setDisplayValue('assigned_to', 'John Doe');
Method | Purpose | Example Output |
getValue() | Raw value from DB | e3f2c1d3... (sys_id) |
getDisplayValue() | Human-readable value | John Doe |
setDisplayValue() | Set field using display value | Resolves to sys_id |
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:51 AM
Hello @22eg105p57
I believe you are doing great.
Did my reply answer your question?
If my response helped, please mark it correct and close the thread so that it benefits future readers.
As per new community feature you can mark multiple responses as correct.
Thanks & Regards
Viraj Hudlikar