- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2023 02:14 PM
Is it possible to get the display value of a field for the result of a GlideQuery? I was hoping for something similar to a GlideRecord result, e.g., gr.getValue('state').getDisplayValue(), but I haven't found anything after much Googling.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2023 07:54 PM - edited ‎10-06-2023 07:55 PM
@Joseph Warner You can use $DISPLAY Keyword concatenated with you column name to get the display value of a reference/choice field. For state you should 'state$DISPLAY' in select statement.
Here is the sample query to get State and assigned to display values from incident table.
var query = new global.GlideQuery('incident')
.orderBy('number')
.limit(5)
.select('priority', 'state$DISPLAY','assigned_to$DISPLAY') //Returns a stream of records wrapped in a Stream object.
.toArray(100); //Terminal method in the Stream class that executes the query and returns the result.
gs.info(JSON.stringify(query, null, 2));
Here I have used $DISPLAY keyword with state and assigned_to field in the select statement.
.select('priority', 'state$DISPLAY','assigned_to$DISPLAY') //Returns a stream of records wrapped in a Stream object.
Here is the output.
Script: [
{
"priority": 1,
"state$DISPLAY": "Closed",
"assigned_to$DISPLAY": "Charlie Whitherspoon",
"sys_id": "9c573169c611228700193229fff72400"
},
{
"priority": 1,
"state$DISPLAY": "On Hold",
"assigned_to$DISPLAY": "Howard Johnson",
"sys_id": "9d385017c611228701d22104cc95c371"
},
{
"priority": 1,
"state$DISPLAY": "In Progress",
"assigned_to$DISPLAY": "Beth Anglin",
"sys_id": "e8caedcbc0a80164017df472f39eaed1"
}]
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2023 02:50 PM
Hi Joseph,
Have you tried gr.getDisplayValue('state');?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 06:51 AM
@Brad Bowman , that was a good thought, but I tried that and it does not work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2023 07:54 PM - edited ‎10-06-2023 07:55 PM
@Joseph Warner You can use $DISPLAY Keyword concatenated with you column name to get the display value of a reference/choice field. For state you should 'state$DISPLAY' in select statement.
Here is the sample query to get State and assigned to display values from incident table.
var query = new global.GlideQuery('incident')
.orderBy('number')
.limit(5)
.select('priority', 'state$DISPLAY','assigned_to$DISPLAY') //Returns a stream of records wrapped in a Stream object.
.toArray(100); //Terminal method in the Stream class that executes the query and returns the result.
gs.info(JSON.stringify(query, null, 2));
Here I have used $DISPLAY keyword with state and assigned_to field in the select statement.
.select('priority', 'state$DISPLAY','assigned_to$DISPLAY') //Returns a stream of records wrapped in a Stream object.
Here is the output.
Script: [
{
"priority": 1,
"state$DISPLAY": "Closed",
"assigned_to$DISPLAY": "Charlie Whitherspoon",
"sys_id": "9c573169c611228700193229fff72400"
},
{
"priority": 1,
"state$DISPLAY": "On Hold",
"assigned_to$DISPLAY": "Howard Johnson",
"sys_id": "9d385017c611228701d22104cc95c371"
},
{
"priority": 1,
"state$DISPLAY": "In Progress",
"assigned_to$DISPLAY": "Beth Anglin",
"sys_id": "e8caedcbc0a80164017df472f39eaed1"
}]
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 06:56 AM
@Sandeep Rajput, thank you for clarifying with a thorough example. Yes, the $DISPLAY flag was the solution.