Restrict list choices based on multiple fields

JB6
Tera Contributor

Hey all,

I've been trying to make this work for a day or so and can't get the results I'm looking for.

It's simple to restrict the choices in a list field based on a dependent field. Category and Subcategory are already setup for this functionality, but I need a way to restrict the Subcategory field based on both the Category field and the Incident Type field.

I have two Incident Types: Dental and IT. I've already restricted the categories available based on the Incident type that is chosen, but I then need to restrict the subcategories based on this as well. So, if I choose Dental as the incident type and Hardware as the category, I only want a specific set of choices from the list of choices available under Hardware. Because Hardware is a choice for both Dental and IT Incident Types, I'm always getting all choices for Hardware under both Dental and IT.

I've tried using a Business Rule and a Client Script on the Incident table, but neither are doing what I need.

Client Script that I've tried:

 

 

function onChange() {

    var category = g_form.getValue('category');

    var type = g_form.getValue('u_incident_type');

    if (type == 'Dental') {

        alert('Help');

        if (category == 'Hardware') {

            g_form.clearOptions('subcategory');

            g_form.addOption('subcategory', 'Computer', 'Computer');

        }

    }

}

 

 

The alert works, so I know the script is running, but it's not clearing the options. I can see that it is acting on the subcategory because it sets the value to Computer, but the other options are still there.

Also, I need this to work in the Service Portal as well.

Any help is much appreciated.

 

I've also posted this question on reddit.

11 REPLIES 11

@Subhashis Ratna, I do have it set to All.  I've tried all three settings for UI Type with no luck.

Hi @JB6 

Could you please share your cs script or any snapshots , Let me recheck .

Thanks

Subhashis