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.

Get the display value of list collector variable values selected through flow designer

Phanideepthi
Tera Contributor

Hi All,

 

We are working on a catalog item where we have a list collector variable("additional services") getting from question_choice table . Now we need to get the values selected in the list collector into request description. When we are adding the variable it is populating with sysID's of the values selected. So now how can we get the text values using a flow designer. 

Phanideepthi_0-1763388943210.png

 

 

Thanks in advance.

11 REPLIES 11

Hi Ankur,

Thanks for your reply. I did tried with set flow variable and the script accordingly. But getting empty values during execution. please find the script and output.

 

var arr = [];
var val = fd_data._1__get_catalog_variables.need_any_additional_service_account;
var rec = new GlideRecord('question_choice');
rec.addQuery('sys_id', 'IN', val);
rec.query;
while(rec.next()){
    arr.push(rec.getDisplayValue('value'));
}
return arr.toString();
 
Phanideepthi_0-1763494715057.png

Help me where I am doing wrong

@Phanideepthi 

are you sure you are using correct variable name?

try adding log to see

also do you want value or text from question_choice?

var arr = [];
var val = fd_data._1__get_catalog_variables.need_any_additional_service_account.toString();
gs.info('my value is' + val);
var rec = new GlideRecord('question_choice');
rec.addQuery('sys_id', 'IN', val);
rec.query;
while (rec.next()) {
    arr.push(rec.getValue('value')); // use text field name if you want here
}
return arr.toString();

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Yes the variable I am using is correct and I have updated the script as per above. still the same issue

@Phanideepthi 

what came in logs? share screenshots

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Phanideepthi 

any update to this?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader