The CreatorCon Call for Content is officially open! Get started here.

Retrieve choice label not the value

codedude
Mega Expert

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...

  }

}

12 REPLIES 12

If you're going to the sys_choice table for your results, you should also include table and element or you could get a lot of answers back (perhaps incorrect ones.)



You might even think to include the language (from the returned value of gs.getSession().getLanguage()) as well.


Astricht
Kilo Explorer

getDisplayValue() doesn't seem to be working for me on a select box populated via a client script:

//excerpt of the code populating the subtype select box
g_form.addOption('subtype', 'cc_gl', 'Cost Centre Query');
//producer.subtype.getDisplayValue() shows the variable name not the label
current.short_description = producer.query_type.getDisplayValue() + ' - ' +  producer.subtype.getDisplayValue() + ' ' + producer.od.getDisplayValue();

 

The result is:

find_real_file.png

I was expecting "Account Query - Cost Centre Query - OD32 MENS ACCESSORIES"

Any insight would be much appreciated! 

Did you get any solution for this Astricht? If yes, please let us know. I am facing the same issue.