- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 06:00 PM
The official reference does not specify any arguments for the getDisplayValue () method.
Therefore, I think the usage of current. <FieldName> .getDisplayValue () is correct,
At this time, an error will occur if fieldName does not exist.
It is hard to check the existence of fieldName every time.
Is there a way to get a displayvalue that works even if fieldName doesn't exist, like current.getValue ("fieldName")?
Solved! Go to Solution.
- Labels:
-
Studio

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 09:05 PM
You can use the following function in Global as an alternative to getDisplayValue()
var value = gs.getDisplayValueFor(current.getTableName(),current.getValue('sys_id'),'number');
GlideSystem.getDisplayValueFor() | ServiceNow Legacy API
This will return the display value or null if the field does not exist.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 09:05 PM
You can use the following function in Global as an alternative to getDisplayValue()
var value = gs.getDisplayValueFor(current.getTableName(),current.getValue('sys_id'),'number');
GlideSystem.getDisplayValueFor() | ServiceNow Legacy API
This will return the display value or null if the field does not exist.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 09:18 PM
Hi. Thank you for your reply.
It is “Legacy API”...?
What is the difference from “SCOPED API”?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 09:27 PM
Don't let the name "legacy" scare you - it is just what ServiceNow call it in their documentation.
If you are developing in an Application Scope, you must refer to the Scoped API, as some global functions are not available.
More about Scoped API here.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022