How to get list collector variable selected values

Aishwarya20
Tera Contributor

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

10 REPLIES 10

Pravindra1
Tera Guru

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]);
    }
}

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Aishwarya20 

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?

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

Aishwarya20
Tera Contributor

Actully I want to write server side script there is any way to get the values from server side script?

@Aishwarya20 

where do you wish to write the script i.e. server side?

is it workflow or flow designer?

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