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:22 AM
HI Adam,,
Let me know if its not helpful...
Service Catalog - Client Script To Add Options To A Drop Down Field
Regards,
Sadasiva
Please mark helpful/ correct based on the impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:26 AM
Thank you for all the replies. However, I only have department admin access, and I can't find an option for 'choices'. I'm not fully sure if I have access to that with my current entitlement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:29 AM
Hi Adam,
Thanks for the update. For best scalability and maintainability, work with someone who has full admin rights to do this without scripting. That's really going to save you time and money in the long run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 06:30 AM
HI Adam,
Service-now Always Recommends to use OOB Functionality, but i don't know why you are trying to achieve this using Script.
No need to write any script to define dependent value for a choice list fields.
Please follow the steps
To define a static list of available options:
- Navigate to a form on which the field appears.
- If the choice list is dependent on another field, enter the choice value on which these options depend.
- For example, on the incident table, the Subcategory is dependent on the Category. To customize which subcategory choices are available for the hardware category, select Hardware in the Category field.
- Right-click the field label and select Configure Choices (Personalize Choices in versions prior to Fuji).
- Use the slushbucket to rearrange the order, add, or remove items or to create new items.
- Click Save.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke