- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 09:00 AM - edited 04-08-2024 02:36 AM
Hi everyone
I created a catalog item (see screenshot below), but the part I am battling with is to create a dropdown field with categories, and when one of those categories have been selected, it must give a list of sub-categories to choose from. I am not sure if I am making sense. Any guidance would be appreciated. We are on the Utah version currently.
Regards
Thereza
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 09:13 PM
Hi @Thereza Van der
For the “Subcategory” variable, you need to make it’s choices dependent on the “Category” selection. Unfortunately, ServiceNow doesn’t support dynamic refilling of choice lists out of the box based purely on parent choices without some customization, such as using Reference Qualifiers or Client Scripts.
Step1: Remove all choices from Support subcategory > Save the Catalog Item
Step2: Create a Catalog Client Script > Onchange > Support Category
var category = g_form.getValue('support_category'); //backend name of variables
var subcategoryField = 'support_sub_category'; // backend name of variables
// Clear current options
g_form.clearOptions(subcategoryField);
// Example: Adjust subcategories based on category
if (category == 'application_access') {
g_form.addOption(subcategoryField, 'change_password', 'Change Password and Reset Password');
g_form.addOption(subcategoryField, 'login_failure', 'Login failures permission issues');
// Add more as required…
} else if (category == 'user_management') {
g_form.addOption(subcategoryField, 'create_users', 'Create Users');
// Add more as required…
}
// Repeat for other categories…
Note: Please mark this as Helpful/Accepted if this helps you to understand. This will help both me and the community.
Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 09:07 AM
You need to create 2 variables
- category
- Sub Category and then populate these value in same
Please make sure cat - sub cat are linked as parent child.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 09:34 AM
Hi @Thereza Van der
For dependency subcategory on category,
first create two variable named as Support category and Support Sub-category on your catalog item and then add choices on it. After that do dependencies based on selected category. Please follow below steps:
1. Navigate to maintain items in filter navigator, then search for your catalog > open it and click on edit in catalog builder from the top of banner of form.
2. Click Questions on left menu and then Insert Questions from the open form.
Question Type: Choice
Sub Type: Dropdown (with fixed)
Question Lable: Support Category
Click Continue to choices.
In available choices click on plus icon and add all the categories name in Display Name--> Application Access-->User Management--> reporting solution
Click Insert Question
Same for all subcategory fields
Note: Please mark this as Helpful/Accepted if this helps you to understand. This will help both me and the community.
Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 12:57 PM
Thanks Deepak, but how do I tell ServiceNow that 'Application access' is the parent and the sub-categories below are the children of 'Application access'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 09:13 PM
Hi @Thereza Van der
For the “Subcategory” variable, you need to make it’s choices dependent on the “Category” selection. Unfortunately, ServiceNow doesn’t support dynamic refilling of choice lists out of the box based purely on parent choices without some customization, such as using Reference Qualifiers or Client Scripts.
Step1: Remove all choices from Support subcategory > Save the Catalog Item
Step2: Create a Catalog Client Script > Onchange > Support Category
var category = g_form.getValue('support_category'); //backend name of variables
var subcategoryField = 'support_sub_category'; // backend name of variables
// Clear current options
g_form.clearOptions(subcategoryField);
// Example: Adjust subcategories based on category
if (category == 'application_access') {
g_form.addOption(subcategoryField, 'change_password', 'Change Password and Reset Password');
g_form.addOption(subcategoryField, 'login_failure', 'Login failures permission issues');
// Add more as required…
} else if (category == 'user_management') {
g_form.addOption(subcategoryField, 'create_users', 'Create Users');
// Add more as required…
}
// Repeat for other categories…
Note: Please mark this as Helpful/Accepted if this helps you to understand. This will help both me and the community.
Regards
Deepak Sharma