URGENT HELP- How to make sub-category mandatory only if it has dropdown.

ST9
Tera Contributor

Hi All,

How can i make a sub-category 2 field mandatory (which is dependent on sub-category 1 field) only when it has dropdown when the case is getting resolved.

I tried with UI policy but the problem is few of the sub-cat2 does not have any dropdown. So while using UI policy it will make sub-cat2 mandatory all the time even though it does not have any dropdown.find_real_file.png

 

1 ACCEPTED SOLUTION

1) You are using many brackets unnecessarily

2) You should pass sysid for assignment group reference fields

Update your script as below and pass sysids where ever I mentioned in script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading || newValue === '') {
return;
 }
if((newValue == '101') && ((g_form.getValue('assignment_group')=="sysid of group1")||(g_form.getValue('assignment_group')=="sysid of group2")||(g_form.getValue('assignment_group')=="sysid of group3")||(g_form.getValue('assignment_group'))=="sysid of group4"))
	
{
var subcat2 = g_form.getControl('u_sub_category_2'); 
var options = subcat2.options.length;

if(options > 1)
{
g_form.setMandatory('u_sub_category_2', true);
}
}
}

 

Mark as correct and helpful if it solved your query.

Regards,
Sumanth

View solution in original post

17 REPLIES 17

Feel free to reach out if you have further questions or else you can mark an answer as correct and helpful to close the thread so that it benefits future visitors also.

Regards,
Sumanth

Hi Sumanth,

One more query, while resolving the case, i have not filled the sub-cat and sub-cat2. Since subcat2 length>1 or not will be identified only when sub-cat is filled. At that time it is not making it as mandatory.

1. While resolving the case with no sub-cat and sub2 selected.

find_real_file.png

2. After selecting the sub-cat, it is still not making the sub-cat2 as mandatory. and the case is getting saved with sub-cat2 filled

find_real_file.png

 

can you please help.

ST9
Tera Contributor

@SUMANTH DOSAPATI can you please help on above query?

 

Hi,

Please mark an answer as correct for this question and create a new question for your new requirement so that it will not confuse others.

You can tag me in that new question so that I can help quick.

 

Regards,
Sumanth

Mark as correct if the answer solved your query.

You can create new question for new queries.

 

Regards,

Sumanth