Catalog Item to show subcategory based on dependant category

Frans Brus - No
Tera Guru

I have a simple (?) idea but somehow I do not seem to get it working...
I want to create a catalog item so employees can enter there own tickets.
So i created a simple form which will result in a Incident.

I placed the 'category' field on the form.
And I also placed the field subcategory on the form.

Now I want to show the subcategories only based on the dependant value form category.
These values are in the 'sys_choice' table.
The values needed are "name=incident^element=subcategory^inactive=false"
The dependent value's here are the same as the values from the field category.

For example:
Category: Applications
Subcategory: ServiceNow, Salesforce, Excel, Word, Powerpoint.

Category: Connectivity
Subcategory: Wi-Fi, VPN, Bluetooth

 

The field category:

find_real_file.png

With the field subcategory i'm stuck.

I tried several type of fields Select Box, Lookup Select Box, Reference but I doesn't work correctly.
I tried a Reference qualifier, als did try a Catalog Client  Script.

Currently it show all the values from the choice list, but i somehow does not use the dependant value.

find_real_file.png

Here is the example of the Catalog Client Script (on a secondary field 'subcat')

find_real_file.png

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }

    if (newValue == '') {
        g_form.setVisible('subcat', false);
    } else {
        g_form.clearOptions('subcat');

        //get the possible values
        var possibleChoices = new GlideRecord('sys_choices');
        possibleChoices.addQuery('table', 'incident');
        possibleChoices.addQuery('element', 'subcategory');
        possibleChoices.addQuery('dependant_value', newValue);

        while (possibleChoices.next()) {
            g_form.addOption('subcat', possibleChoices.value, possibleChoices.label);
        }
        g_form.setVisible('subcat', true);
    }
}

Somebody who can help me out?

I don't want the subcategories hard-coded in the script, but i want to make use of values in the choices table.

Thanks!

1 ACCEPTED SOLUTION
3 REPLIES 3

Thanks, this worked!

Chandrashekar t
Tera Guru

If the this change required in incident table. Go to the incident form open the config dictionary of sub category .   You can seen and mention the dependent field like below from category. 

find_real_file.png