Get list of choice field values with display values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2012 10:33 AM
From a element descriptor I can get the dictionary elements of the field. I am using following code for the same.
var gr = new GlideRecord('cmdb_ci_ip_address');
gs.setLimit(1);
gr.query();
if (gr.next())
{
var choices = gr.getElement('ip_version').getChoices();
// need list of choice display values
}
Is there OOB function to get the display values list of a choice field?
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2018 02:21 AM
getChoices() method returns Java Array list. j2js() function helped to convert it to array. Saved me a lot of effort.
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
// urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3
var choices = glideRecord.urgency.getChoices();
gs.info(choices);
var choiceList = j2js(glideRecord.urgency.getChoices());
gs.print(choiceList.length);
for (var i=0; i < choiceList.length; i++ ) {
gs.print(choiceList[i]);
}