Monday, November 7, 2016

How to refresh Drop down list of values based on other 'Select Box' Value in Service Catalog

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



3 comments: