Questing regarding catalog

supriya1kum
Tera Contributor

Suppose during the catalog making .. i have made one variable that is "Language(selectbox)" and in the language drop down we have choices like "arabic" , "swiss" , "us" .

And i have made one "Keyboard" variable also ... so if i select the "arabic" option from language drop down it should automatically generate "wired-arabic standard" and "wireless-arabic standard" in the "keyboard" drop down .

And similarly for the other options in the language drop down .

 

How can i do this ?

I am also attaching the screenshots of this .

Please help asap.

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

If 'Keyboard' is a select box, you can use g_form.addOption in an onChange Catalog Client Script

https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/Glid... 

Rajesh Chopade1
Mega Sage

hi @supriya1kum 

you can create a Client Script to dynamically populate the "Keyboard" variable based on the selected language. Create 'onChange' client script on 'Language' variable.

In script section you need to check the language and set the options accordingly, you can have look on bellow sample script for your reference:

function onChange(control, oldValue, newValue) {
    var keyboardChoices = [];

    if (newValue === 'Arabic') {
        keyboardChoices = [
            { value: 'wired-arabic-standard', label: 'Wired Arabic Standard' },
            { value: 'wireless-arabic-standard', label: 'Wireless Arabic Standard' }
        ];
    } else if (newValue === 'Swiss') {
        keyboardChoices = [
            { value: 'wired-swiss-standard', label: 'Wired Swiss Standard' },
            { value: 'wireless-swiss-standard', label: 'Wireless Swiss Standard' }
        ];
    } else if (newValue === 'US') {
        keyboardChoices = [
            { value: 'wired-us-standard', label: 'Wired US Standard' },
            { value: 'wireless-us-standard', label: 'Wireless US Standard' }
        ];
    }

    // Clear existing choices
    g_form.clearOptions('keyboard');

    // Add new choices
    for (var i = 0; i < keyboardChoices.length; i++) {
        g_form.addOption('keyboard', keyboardChoices[i].value, keyboardChoices[i].label);
    }
}

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh