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



4 comments:

  1. Thanks for the post, If you are looking for Online Training on ServiceNow go here.

    ReplyDelete
  2. This is a helpful tip for ServiceNow developers! Dynamically refreshing select box values based on user input is a common requirement in web applications. Your solution provides practical guidance. For those in ServiceNow development, I've been researching Agentic AI training review in Bangalore Electronic City to understand how AI is being integrated with enterprise platforms. Thanks for sharing this practical development tip!

    ReplyDelete