How Can we use " getDisplayValue()" in GlideRecord()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2017 11:52 AM
Plse friends don't give your replay with below mentioned code
var list = current.watch_list.getDisplayValue();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
gs.print("Display value is: " + array[i]);
}
i am learner so plse explain , i want to know where we use, how we use in GlideRecord..............
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2017 01:00 PM
Hi Kishore,
Please find the modified code below. I hope this is what you are looking for.
var list = current.watch_list;
var array = list.toString().split(",");
for (var i=0; i < array.length; i++) {
gs.print("Display value is: " + array[i]);
}
I hope this helps.Please mark correct/helpful based on impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2017 02:50 PM
Hi
Please check the link below. section 5.5
Coding Best Practices - ServiceNow Wiki
Thanks,
Harshvardhan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2017 05:53 PM
GlideRecord getDisplayValue()
https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=r_GlideRecord-getDisplayValue
var gr = new GlideRecord('incident');
gr.initialize();
gs.print(gr.getDisplayValue());
INC1000010
GlideElement getDisplayValue()
var fields = current.getFields();
for (var i = 0; i < fields.size(); i++) {
var field = fields.get(i);
var name = field.getName();
var value = field.getDisplayValue();
gs.print(i + ". " + name + "=" + value);
}
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
03-19-2017 09:07 PM
If your objective in this case is to identify the user's associated with the watch_list, then this will do it:
BTW, avoid calling arrays 'array'. (Or any other data type)
var watch_list = current.getValue('watch_list'); // get the comma separated sys_ids
var list = watch_list.split(","); store it in an array
for (var i=0; i < list.length; i++) {
var user = new GlideRecord('sys_user');
user.get(list[i]);
gs.print("Display value is: " + user.getDisplayValue());
}