Use case: Based on 'First' Select Box selected value, Refresh the Second 'Select Box' values for a Service Catalog item in Service Now
Solution
- Create a new 'Catalog Client Script'
- Applies to 'Service Catalog Item'
- Type - 'onChange'
- Catalog Item - Select the appropriate catalog item, for which you want to implement this functionality
- Varaiable Name - 'Select appropriate variable' In this example, First 'Select Box' variable name
- Write the script as below
g_form.clearOptions('state');
var cat = g_form.getValue('country');
if(cat == "usa"){
g_form.addOption('state','WI','Wisconsin');
g_form.addOption('state','TX','Texas');
}
if(cat == "india"){
g_form.addOption('state','AP','Andhrapradesh');
g_form.addOption('state','TG','Telangana');
}
Solution
- Create a new 'Catalog Client Script'
- Applies to 'Service Catalog Item'
- Type - 'onChange'
- Catalog Item - Select the appropriate catalog item, for which you want to implement this functionality
- Varaiable Name - 'Select appropriate variable' In this example, First 'Select Box' variable name
- Write the script as below
g_form.clearOptions('state');
var cat = g_form.getValue('country');
if(cat == "usa"){
g_form.addOption('state','WI','Wisconsin');
g_form.addOption('state','TX','Texas');
}
if(cat == "india"){
g_form.addOption('state','AP','Andhrapradesh');
g_form.addOption('state','TG','Telangana');
}