Get display values from a list collection in a catalog item

Clement Dos San
Tera Contributor

Hello,

How can I get the diplayed values of a list collector ,instead of sys_id, in a catalog item, without a gliderecord to resolve the sys_id.
I tried :

alert(g_form.getDisplayBox("mylistcollector").value);
alert(g_form.getDisplayBox("mylistcollector"));
alert(g_form.getValue("mylistcollector"));
alert(g_form.getDisplayValue("mylistcollector"));
alert(g_form.getReference('mylistcollector'));

var list= g_form.getReference('mylistcollector', getList);
function getList(list) {
alert('gg ' + list.name);
}

Either it does not work, or I have the sys_id

Here is my list collector

find_real_file.png

 

Thank you

Clement

5 REPLIES 5

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi,

        Please go through below thread it may help your requirement

https://community.servicenow.com/community?id=community_question&sys_id=0ab0c765db98dbc01dcaf3231f96...

Kindly mark correct and helpful if applicable 

Thank you but I Have this error

find_real_file.png

 

on this line

var varName = "mylistcollector"; //list collector variable name
var leftBucket = gel(varName + '_select_0');
var rightBucket = gel(varName + '_select_1');
var selectedOptions = rightBucket.options; //get the options in right bucket
var opt = [];
for (var j = 0; j < selectedOptions.length; j++) {
opt.push(selectedOptions[j].innerHTML);
}
alert(JSON.stringify(opt));

 

Musab Rasheed
Tera Sage
Tera Sage

Hi @Clement Dos Santos ,

Please go through following links, Mark my answer as correct if that helps.

https://community.servicenow.com/community?id=community_question&sys_id=2dc80b61db5cdbc01dcaf3231f96196c

https://community.servicenow.com/community?id=community_question&sys_id=36338be1dbd8dbc01dcaf3231f961954

https://community.servicenow.com/community?id=community_question&sys_id=941cc185db179f400be6a345ca961954

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

https://community.servicenow.com/community?id=community_question&sys_id=2dc80b61db5cdbc01dcaf3231f96196c
As explained in my demand , I don't want to use gliderecord on the client side for perfomance reason. I'll use it at last resort

https://community.servicenow.com/community?id=community_question&sys_id=36338be1dbd8dbc01dcaf3231f961954
I have the same error as above on the option attribute
onSubmit script error: TypeError: Cannot read properties of null (reading 'options'):
var arr=[];
var select_id=$('mylistcollector_select_1');
for(i=0; i<select_id.options.length; i++){
arr.push(select_id.options[i].text);
}
alert(arr);

 

https://community.servicenow.com/community?id=community_question&sys_id=941cc185db179f400be6a345ca961954
var varDisp = g_form.getDisplayBox(g_form.resolveNameMap(“mylistcollector”)).value;
This is the only line of code I haven't tried but it does not work. The alert display show me an empty popup

Thank you