How to make Sub Category mandatory

Alon Grod
Tera Expert

Hi,

 

I have the fields Category and Sub Category on the incident table. Sub Category values are dependent on Category. For some values on category there are sub categories and some of the values of categories don't have values in sub category. How can I make Sub Category field mandatory only if he has values according to the Category that was chosen ?

1 ACCEPTED SOLUTION

@Alon Grod ,

 

This solution is tried and tested in the PDI and it is giving correct response.
Please check my attached screenshot from my PDI

PRINCE_ARORA_0-1678637918435.png

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

10 REPLIES 10

AndersBGS
Tera Patron
Tera Patron

Hi @Alon Grod,

 

you can make a Ui policy using condition builder to state, that if some specific is chosen in the category, then subcategory should be mandatory.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

@AndersBGS is there any way to make it work in general without mention specific categories?

Prince Arora
Tera Sage
Tera Sage

@Alon Grod ,

 

If you want to make it mandatory everytime, please follow the below mentioned step:

PRINCE_ARORA_0-1678623294946.png

 

 

2) OR you can try making it mandatory from UI policy or client script, please let me know if you need more info on it.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

 

Sai Shravan
Mega Sage

Hi @Alon Grod ,

 

Here the script you can give a try with onchange client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if ((isLoading && newValue === '') || newValue === '') {
        g_form.setMandatory('subcategory', false);
        return;
    } else {
        var subcat = g_form.getControl('subcategory');
        var options = subcat.options.length;
        alert(options);
        if (options > 0) {
            g_form.setMandatory('subcategory', true);
        } else {
            g_form.setMandatory('subcategory', false);
        }
    }
}

 

Regards,
Shravan.

Please mark as help and correct answer if this helps you.

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you