How to add list collector to the form

Sweety11
Kilo Contributor

Hello

Can anyone explain me, ow to add a list collector to a form

Thanks in advance

16 REPLIES 16

Service_RNow
Mega Sage

HI,

please follow the below link:

https://www.covestic.com/blog/servicenow-tips-making-list-collectors-useful/

Hope this helps.
please mark my answer as ✅ Correct & Helpful based on the validations

Marrysmithgs
Tera Contributor

@Sweety11 wrote:

Hello

Can anyone explain me, ow to add a list collector to a form

Thanks in advance


List collector variables are a great way (currently the only way) to allow a user to select multiple options from a referenced table in a single variable on a service catalog item. The list collector variable allows you to choose from one to many (potentially hundreds or more) selections. What if you wanted to limit the number of items like my hair transplant turkey list goes long that a user could select? This script does exactly that. It restricts the selected items list on a list collector variable to whatever amount you choose. Just use the catalog client script below and set the variables for the maximum number of selections and the name of the variable to apply the restriction to.

 

Name: Limit Selections
Type: onChange
UI type: Desktop
Script:

 

function onChange(control, oldValue, newValue, isLoading) {
    //Limit the number of selected options in a list collector
    //Specify the max options and variable name below
    var maxOptions = 5;
    var varName = 'users';
    var leftBucket = gel(varName + '_select_0');
    var rightBucket = gel(varName + '_select_1');
    var selectedOptions = rightBucket.options;
    if(selectedOptions.length > maxOptions){
        //Move any options with IDs greater than maxOptions back to left bucket
        var selectedIDs = [];
        var index = 0;
        for(var i = maxOptions; i < selectedOptions.length; i++){
            selectedIDs[index] = i;
            index++;
        }
        //Move options and sort the left bucket
        moveSelectedOptions(selectedIDs, rightBucket, leftBucket, '--None--');
        sortSelect(leftBucket);
        alert('You cannot select more than ' + maxOptions + ' options.');
    }
}