List collector variable choices are visible based on other list collector type variable choices

Manohararuna
Tera Contributor

Hi Everyone,

Actuallay my end user trying to select multiple option.So i just change the variable type from Slect box to List Collector

1-reuirement-Landscape - Sandbox

Roles - it support  and functional support

Client - 300 and 450

 

2.requirement-Landscape - Development

Client - 100 and 200

3-Requirement-I f role having the option-

                                          DS4 100  DS4 200  DCA 100

  Functional                        Yes            Yes              Yes
Cross Functional                                    Yes           Yes

(CAR and S4) Y
Security                                Yes            Yes             Yes
Basis                                     Yes             Yes              Yes
Development                      Yes             Yes              Yes
Fiori Administration           Yes             Yes              Yes
CAR Configurator                                                        Yes

for this i written the client script and Script include. below

 

var Globalutils = Class.create();
Globalutils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getClientChoice: function() {
    var roles = this.getParameter('sysparm_roles');
    var clientChoices = [];
    return JSON.stringify(clientChoices);
},
    type: 'Globalutils'

});
 
 
 
Vlient script-
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

var ga = new GlideAjax('Globalutils'); // Replace with your Script Include name
    ga.addParam('sysparm_name''getClientChoices'); // Replace with your Script Include function name
    ga.addParam('sysparm_roles', newValue); // Pass the selected roles
    ga.getXMLAnswer(function(answer) {
        var clientChoices = JSON.parse(answer);

        // Get the list collector elements for the Client variable
        var clientVarName = 'client'// Replace with your Client variable name
        var leftBucket = gel(clientVarName + '_select_0');
        var rightBucket = gel(clientVarName + '_select_1');

        // Clear existing options
        clearOptions(leftBucket);
        clearOptions(rightBucket);

        // Populate the list collector
        for (var i = 0; i < clientChoices.length; i++) {
            var option = document.createElement("option");
            option.value = clientChoices[i].value;
            option.text = clientChoices[i].label;
            leftBucket.appendChild(option); // Add to the left bucket (available)
        }
    });
}

// Helper function to clear options
function clearOptions(selectBox) {
    while (selectBox.options.length > 0) {
        selectBox.remove(0);
    }
}  please correct the code as poet the requirement
1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Manohararuna 

so earlier variable was Select box with some choices and later you made it as List Collector?

what's the issue now?

what are you trying to achieve?

💡 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