- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:46 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 04:50 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 03:24 AM
Hi ST,
You can use UI policy for this in following manner:
Please mark correct and helpful.
Thank you
Gaurav Rotke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 03:31 AM
Hi,
Please avoid creating duplicate questions.
Keep the discussion going in the original question.
https://community.servicenow.com/community?id=community_question&sys_id=7ece3f7bdb3c11501227db85ca96...
Also, no matter how urgent your requirement is, take a few minutes extra to specify your question.
Have a look at the 10+ tips article.
That way you are more likely to get a complete and correct answer the first time around, which saves time for everyone.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2022 05:06 AM
Hi. If my answer has helped you resolve your issue, Please mark Correct and Helpful. This way, other users may also benefit from the thread. Thanks!
Martin Ivanov
Community Rising Star 2022
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024