Retrieve choice label not the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 08:34 AM
I have a glide record where I am pulling the short description, update on and stage fields. The stage field I am having a problem with, it is giving me the value, but I really need to human readable label. What is the best way to accomplish this? This is all being done in the client script section of the UI Page. Here is my script:
for(var r = 0; r < requestsRITMs.length; r++)
{
var grRITMDetails = new GlideRecord('sc_req_item');
grRITMDetails.addQuery('number', requestsRITMs[r]);
grRITMDetails.query();
while(grRITMDetails.next())
{
var description = grRITMDetails.short_descritpion;
var date = grRITMDetails.sys_updated_on;
var stage = grRITMDetails.stage; // this is where I am getting the value not the label. I want the label...
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 08:38 AM
Hi Josh,
Use the getDisplayValue() method.
var stage = grRITMDetails.stage.getDisplayValue();
FWIW, it looks like you are also missing an if (grRITMDetails.next9)) or possibly a while loop with the same condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 08:43 AM
Sorry - I just didnt paste that portion in, it is there. I will paste it in to not cause confusion for future peeps.
I have tried that and it did not work...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 08:52 AM
That's odd, it works for me. I just tried this in script background and got a display value and value as expected. Try it with one of your request item sys_ids.
var ritm = new GlideRecord('sc_req_item');
ritm.get('9c39501edb8be2002e38711ebf961909');
gs.debug('stage = ' + ritm.stage.getDisplayValue() + ' value = ' + ritm.stage);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 09:04 AM
it worked in background script for me too... Would it have anything to do with it being in a UI page in the client script section?