Get choice list by script in OOB Script Include. We don’t need to write an additional script to query from ServiceNow using GlideRecord.

var options = [];
var choices = new GlideChoiceList();
var choiceList = choices.getChoiceList('table-name', 'field-name');
for (var i = 0; i < choiceList.getSize(); i++) {
    options.push({
        'value': choiceList.getChoice(i).getValue(),
        'label': choiceList.getChoice(i).getLabel()
    });
}
gs.print(JSON.stringify(options));

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *