Create dropdown field dependency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 05:52 AM
Hi SNOW Community,
I'm keen on creating two dependent dropdown lists in SNOW. I've gone through all the forum threads and google too, but haven't found a solution so far. I'm not a pro of JS either, hence I'm stuck.
Basically what I would like to do is two hard coded dropdown list, and whichever I select in the 1st list, pre-defined selection options appear in the 2nd. To make it simple for testing, I only have 'value_1' and 'value_2' variables set for select box #1, and a select box #2 without any pre-defined variables. I was trying to resolve this with catalog client scripts with the onChange function, something like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getValue('select_box');
var select_box = newValue;
if (newValue == 'value_2') {
g_form.addOption('select_box_2', 'A', 'a');
g_form.addOption('select_box_2', 'B', 'b');
console.log(success);
}
}
but this obviously doesn't work. Can someone pls help me out?
Thanks in advance.
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:15 AM
Shouldn't need to code it if you're dealing with Choices. When you look at the dictionary entry for a choice, there's an option to specify a field dependency.
Once you've got that established, then you can go to the sys_choice table and for each choice, fill out its dependent value.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:16 AM
Hi Adam,
If I understand correctly, this functionality is built in to ServiceNow. Take a look at incident category and subcategory. When you change the category, the subcategory is changed accordingly (e.g. when category is hardware, subcategory contains CPU, monitor, etc. When you change category to network, subcategory contains DHCP, VPN, etc.)
It's based off the choices and dictionary entry for the dependent field. No scripting necessary.
Customizing Choice Lists - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 02:34 AM
Same requirement i also have,I created widget in portal -2 fileds -Category and Subcategory, based on category field values subcategory fields show the dropdown list
How to achieve this from portal widget
what functionality is required to scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:16 AM
Your requirement to display choices from a dependent field is possible using Client scripts. But you may also try achieving this using below OOB feature, because the data lookup rules are configurable and applies to form/ server side actions (insert/update)
http://wiki.servicenow.com/index.php?title=Data_Lookup_and_Record_Matching_Support#gsc.tab=0