Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How do you get the Choice Value from a Choice field? (not a trick question!)

Not applicable

Assume a GlideRecord, 'gr', with choice field 'os' (operating system).

How do I get the value?

gr.os.getChoiceValue() returns the 'choice label'
gr.os.getDisplayValue() returns the 'choice label'
gr.os.getElementValue() returns the 'choice label'
gr.os.getLabel() returns the 'field name'
gr.os.getValue() returns undefined

My understanding of Choice lists was that the 'label' was the human readable name and is more prone to changing to meet user tastes in spelling, wording, whatever.

And that 'value' was the ID of the choice being made and is NOT meant to be human readable.

Thanks,
Afshin

5 REPLIES 5

Not applicable

SOLVED, thank you!