- 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 07:09 PM
yes ,we have current.getDisplayValue('assigned_to'); it won't throw error even when the field is empty!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 08:20 PM
Hi. Thank you for your reply.
I understand that you don't throw errors in the way you wrote.
Sorry, But the usage of "current.getDisplayValue ('assigned_to')" is not officially documented, so we can't determine if it's the correct method.
Is there a document that can be recognized as an official usage?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2019 12:26 AM
I can't find any official document for this!!.
Haha ..!! Most of the service portal methods are not officially documented by servicenow but we are still using them 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 07:45 PM
Hi,
you can check whether field is valid or not before using this
var isValid = current.isValidField(<FieldName>);
if(isValid){
current.<FieldName>.getDisplayValue();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader