Create a catalog item with categories and sub-categories

Thereza Van der
Tera Contributor

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.

 

CODI1.jpg

 

Regards

Thereza 

1 ACCEPTED SOLUTION

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


View solution in original post

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Thereza Van der 

 

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.

 

https://www.servicenow.com/community/itsm-articles/category-subcategory-dependency-in-service-catalo...

 

*************************************************************************************************************
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]

****************************************************************************************************************

Deepak Shaerma
Kilo Sage

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.

DeepakShaerma_0-1712247779582.pngDeepakShaerma_1-1712247808230.pngDeepakShaerma_2-1712247834993.png

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

 

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'?

TherezaVander_0-1712260610415.png

 

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