show/hide subcategory options based on an sssignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 03:30 PM
Hello experts, please I need your expertise in this matter, I was asked to add more choices to the subcategory field which depend on a category selection. The subcategory field is a dependent field of the category.
I tried UI policy, client scripts with no luck, I checked other posts and try to use them but with no luck, can you guide me on how I can do it?
Here's the Client script I'm using
this is the UI policy, in when to run, I added the groups. (different alternative I used)
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 03:58 PM - edited 07-08-2025 04:02 PM
Hi @Jesus Nava,
in your script, there is if condition for the assignment group, if it is selected then some values are hidden.
if not selected then some choices are added.
you can try to build the condition as opposite - add the choices if this group is not selected and else to remove. So switch the logics with negation of the condition.
Reference qualifier is not helpful for this and what about decision table?
Refer to this link
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0755115
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 06:11 PM
Hi @Jesus Nava ,
i will suggest use the client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var assignmentGroup = g_form.getValue('assignment_group');
// Clear existing options first to avoid duplicates
g_form.clearOptions('subcategory');
// Add base options that should always be available
g_form.addOption('subcategory', 'base_option_1', 'General Request');
g_form.addOption('subcategory', 'base_option_2', 'General Inquiry');
// Add group-specific options
if (assignmentGroup == '27f93fc47234e58a47ef6f746d43ie') { // IT Group
g_form.addOption('subcategory', '108', 'Hardware Purchase');
g_form.addOption('subcategory', '107', 'Software Purchase');
g_form.addOption('subcategory', '109', 'Access Request');
}
else if (assignmentGroup == 'another_sys_id_here') { // HR Group
g_form.addOption('subcategory', '201', 'Benefits');
g_form.addOption('subcategory', '202', 'Onboarding');
}
// Add more groups as needed
// Optional: Set a default value
g_form.setValue('subcategory', '');
}
If you prefer UI Policies:
Create a UI Policy on the Category field
Conditions: When Category changes
Actions:
(function executeRule(current, previous) {
var category = current.category.toString();
var subcategory = current.subcategory;
// Clear existing options
subcategory.clearOptions();
// Add options based on category
if (category == 'IT') {
subcategory.addOption('108', 'Hardware Purchase');
subcategory.addOption('107', 'Software Purchase');
}
else if (category == 'HR') {
subcategory.addOption('201', 'Benefits');
subcategory.addOption('202', 'Onboarding');
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:28 PM
client script looks good to me.
what debugging did you do?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2025 12:23 PM
Thank you all for your support, I will try with the options you helped me out with and let you know my results,
Regards