other Category option are not visible based on script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
Hi Everyone,
I have used to below script to display Task categories(12 Category option) based Three Assignment group(Workforce Management - APAC,/EU/US) ,But other Task categories(20) are also not display to other Assignment groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago - last edited 11 hours ago
Hi @Manohararuna
This line is the problem
else {
g_form.addOption('u_task_category', '', '');
}
If you have a default set of categories that should be visible to other assignment groups (e.g., 20 categories), then you need to explicitly add those in the else block.
else {
// Add default task categories here
g_form.addOption('u_task_category', 'General', 'General');
g_form.addOption('u_task_category', 'Incident', 'Incident');
// Add the rest of your 20 categories
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Problem with your script is when assignment_group is not one of the "Workforce Management" groups, the code falls into this else block:
g_form.addOption('u_task_category', '', '');
This line adds a single, empty option to the u_task_category dropdown. It doesn't add any of the "20 other Task categories" that they mentioned.
Here's the updated onChange client script I tested on my instance for incident table:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Get the display value of the assignment group
var grpDisplay = g_form.getDisplayBox('assignment_group').value;
var workforceGroups = [
'Hardware',
'Software',
'Service Desk'
];
// Define categories for Workforce Management groups
var wfmCategories = [
{value: 'Configuration', label: 'Configuration'},
{value: 'Login', label: 'Login'},
{value: 'NSO', label: 'NSO'},
{value: 'SFTP - Global scape', label: 'SFTP - Global scape'},
{value: 'Access update', label: 'Access update'},
{value: 'Query', label: 'Query'},
{value: 'Terminate', label: 'Terminate'},
{value: 'Interface', label: 'Interface'},
{value: 'Timeclock', label: 'Timeclock'},
{value: 'Store close', label: 'Store close'},
{value: 'schedule upload', label: 'schedule upload'},
{value: 'Holiday', label: 'Holiday'},
{value: 'Reports -WFC', label: 'Reports -WFC'},
{value: 'Reports -WFAN', label: 'Reports -WFAN'},
{value: 'Automate', label: 'Automate'}, // Note: "Automate" appears twice in your list, assumed intentional
{value: 'Auto Scheduling', label: 'Auto Scheduling'},
{value: 'Forecasting', label: 'Forecasting'},
{value: 'Batch Jobs', label: 'Batch Jobs'},
{value: 'Automate', label: 'Automate'} // Second instance
];
// Define categories for all other groups (your "20 other categories")
var otherCategories = [
{value: 'General Inquiry', label: 'General Inquiry'},
{value: 'System Issue', label: 'System Issue'},
{value: 'Software Request', label: 'Software Request'},
{value: 'Hardware Request', label: 'Hardware Request'},
{value: 'Network Issue', label: 'Network Issue'},
{value: 'Printer Problem', label: 'Printer Problem'},
{value: 'Password Reset', label: 'Password Reset'},
{value: 'Application Support', label: 'Application Support'},
{value: 'Data Access', label: 'Data Access'},
{value: 'Email Issue', label: 'Email Issue'},
{value: 'Collaboration Tools', label: 'Collaboration Tools'},
{value: 'Security Incident', label: 'Security Incident'},
{value: 'New User Setup', label: 'New User Setup'},
{value: 'User Deactivation', label: 'User Deactivation'},
{value: 'Mobile Device Support', label: 'Mobile Device Support'},
{value: 'VPN Access', label: 'VPN Access'},
{value: 'Cloud Service Issue', label: 'Cloud Service Issue'},
{value: 'Database Support', label: 'Database Support'},
{value: 'Reporting Issue', label: 'Reporting Issue'},
{value: 'Training Request', label: 'Training Request'}
];
g_form.clearOptions('u_task_category');
g_form.addOption('u_task_category', '', '-- Select --');
if (workforceGroups.indexOf(grpDisplay) > -1) {
// Populate WFM categories if the group is one of the specified workforce groups
for (var i = 0; i < wfmCategories.length; i++) {
g_form.addOption('u_task_category', wfmCategories[i].value, wfmCategories[i].label);
}
} else {
// Populate other categories for all other assignment groups
for (var j = 0; j < otherCategories.length; j++) {
g_form.addOption('u_task_category', otherCategories[j].value, otherCategories[j].label);
}
}
}
Now you can see when I'm selecting three specified groups (I chose Hardware, Software, and Service Desk for testing), specifc categories are being shown:
and when I'm selecting any of the other groups, other categories are being shown:
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
update as this
- Add the standard 20 categories when the assignment group is not one of the allowed WFM groups.
- Only clear (remove) all options before adding, but always populate with the right set for the current group.
- Avoid duplicate category entries.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var allowedGroups = [
'Workforce Management - EU',
'Workforce Management - APAC',
'Workforce Management - US'
];
var wfmCategories = [
'Configuration', 'Login', 'NSO', 'SFTP - Global scape', 'Access update', 'Query',
'Terminate', 'Interface', 'Timeclock', 'Store close', 'schedule upload', 'Holiday',
'Reports -WFC', 'Reports -WFAN', 'Automate', 'Auto Scheduling', 'Forecasting', 'Batch Jobs'
]; // Use only 18 unique values
var otherCategories = [
// Add the other 20 standard categories here
'Category A', 'Category B', 'Category C', //...etc
];
// Remove previous options before adding
g_form.removeOption('u_task_category');
// Use full category lists, not just blank option for other assignment groups
var grpDisplay = g_form.getDisplayBox('assignment_group').value;
if (allowedGroups.indexOf(grpDisplay) > -1) {
wfmCategories.forEach(function(cat) {
g_form.addOption('u_task_category', cat, cat);
});
} else {
otherCategories.forEach(function(cat) {
g_form.addOption('u_task_category', cat, cat);
});
}
}
š” If my response helped, please mark it as correct ā and close the thread šā this helps future readers find the solution faster! š
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
before select any group it showing None, but after selecting any assignment group then group related task category auto populated .But i want None option every time along with Option like if select Workforce Management group then Task category options showing with None
same way other assignment group related options also
is this below condition correct to show None option-