- 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 11:40 PM
Hello @Thereza Van der ,
There are different ways to achieve this,
The following link can be helpful to your question please go through it.
https://www.servicenow.com/community/developer-articles/solved-dependent-variable-on-catalog-item-us...
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks