How to get list collector variable selected values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 01:55 AM
I have a list collector variable on catalog item and users are selecting multiple values. I want to compare that values with custom table field.
how can I achieve this?
Please suggest me a solution
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 02:21 AM
Hi @Aishwarya20 , As soon as value is selected in List collector variable, it stores all selected values as comma separated string. you can use g_form.getValue('field_name') to get the comma separated values from List collector. You can split it and store it in an array and then loop through the array to get the individual values.
For ex: Below client script will give you the List collector selected values as soon as you select the values to List collector.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var listValues = g_form.getValue('select_groups'); //'select_group' is a list collector variable
var listArr = listValues.split(','); //Storing List collector values in a array.
for (i = 0; i < listArr.length; i++) { //Loop through array to get the individual value
alert(listArr[i]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 02:22 AM
you can use onChange catalog client script on that list collector and use GlideAjax and send the values and then inside the script include function do whatever logic you want
where are you stuck? what did you start with?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 02:39 AM
Actully I want to write server side script there is any way to get the values from server side script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 02:44 AM
where do you wish to write the script i.e. server side?
is it workflow or flow designer?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader