Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to populate the incident choice labels in virtual agent flow trough script.

sekhar6
Tera Contributor

Hai All ,

 I was facing an issue that , i have created a Virtual Agent  flow Design to create the incident ,to populate the category i have written a script in the flow ,it was working fine ,but the back end "values" are population i want to populate the

"Label" values trough script ,i was new to virtual agent please correct me where i have did Rong ,

 below is the script.

var choiceList = global.VAChoiceListGenerator('incident','category')
var options = [];
for (var i=0; i < choiceList.getSize(); i++) {
options.push({'value': choiceList.getChoice(i).getValue(), 'label': choiceList.getChoice(i).getValue()});
}
return options;

Present out put : what i was getting is the choice back end value , i want the label. to populate 

please correct me .

sekhar6_0-1675243627698.png

To get the data i was written Script include to fetch the data from the data base,

script:

function VAChoiceListGenerator(table, field , depended){
var choices = new GlideChoiceListGenerator(table, field, depended);
return choices.get();
}

Please help me on this ,

Thank you,

Sekhar.

 

 

 

 

1 REPLY 1

Shree123
Tera Contributor

options.push({'value': choiceList.getChoice(i).getValue(), 'label': choiceList.getChoice(i).getValue()});

==> use choiceList.getChoice(i).getLabel()