other Category option are not visible based on script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20 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
17 hours ago
Issue likely comes from the use of g_form.removeOption('u_task_category'). This method removes all options from the field, including those that should remain visible, such as the default 'None' option....
check below updated code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var allowedGroups = [
'Workforce Management - EU',
'Workforce Management - APAC',
'Workforce Management - US'
];
var grpDisplay = g_form.getDisplayBox('assignment_group').value;
var taskCategoryField = 'u_task_category';
g_form.clearOptions(taskCategoryField);
g_form.addOption(taskCategoryField, '', '-- None --');
if (allowedGroups.indexOf(grpDisplay) > -1) {
if (grpDisplay === 'Workforce Management - APAC') {
g_form.addOption(taskCategoryField, 'Configuration', 'Configuration');
g_form.addOption(taskCategoryField, 'Login', 'Login');
g_form.addOption(taskCategoryField, 'NSO', 'NSO');
g_form.addOption(taskCategoryField, 'SFTP - Global scape', 'SFTP - Global scape');
g_form.addOption(taskCategoryField, 'Access update', 'Access update');
g_form.addOption(taskCategoryField, 'Query', 'Query');
g_form.addOption(taskCategoryField, 'Terminate', 'Terminate');
g_form.addOption(taskCategoryField, 'Interface', 'Interface');
g_form.addOption(taskCategoryField, 'Timeclock', 'Timeclock');
g_form.addOption(taskCategoryField, 'Store close', 'Store close');
g_form.addOption(taskCategoryField, 'Schedule upload', 'Schedule upload');
g_form.addOption(taskCategoryField, 'Holiday', 'Holiday');
g_form.addOption(taskCategoryField, 'Reports - WFC', 'Reports - WFC');
g_form.addOption(taskCategoryField, 'Reports - WFAN', 'Reports - WFAN');
g_form.addOption(taskCategoryField, 'Automate', 'Automate');
g_form.addOption(taskCategoryField, 'Auto Scheduling', 'Auto Scheduling');
g_form.addOption(taskCategoryField, 'Forecasting', 'Forecasting');
g_form.addOption(taskCategoryField, 'Batch Jobs', 'Batch Jobs');
} else if (grpDisplay === 'Workforce Management - EU') {
g_form.addOption(taskCategoryField, 'Configuration', 'Configuration');
g_form.addOption(taskCategoryField, 'Login', 'Login');
g_form.addOption(taskCategoryField, 'NSO', 'NSO');
g_form.addOption(taskCategoryField, 'SFTP - Global scape', 'SFTP - Global scape');
g_form.addOption(taskCategoryField, 'Access update', 'Access update');
g_form.addOption(taskCategoryField, 'Query', 'Query');
g_form.addOption(taskCategoryField, 'Terminate', 'Terminate');
g_form.addOption(taskCategoryField, 'Interface', 'Interface');
g_form.addOption(taskCategoryField, 'Timeclock', 'Timeclock');
g_form.addOption(taskCategoryField, 'Store close', 'Store close');
g_form.addOption(taskCategoryField, 'Schedule upload', 'Schedule upload');
g_form.addOption(taskCategoryField, 'Holiday', 'Holiday');
g_form.addOption(taskCategoryField, 'Reports - WFC', 'Reports - WFC');
g_form.addOption(taskCategoryField, 'Reports - WFAN', 'Reports - WFAN');
g_form.addOption(taskCategoryField, 'Automate', 'Automate');
g_form.addOption(taskCategoryField, 'Auto Scheduling', 'Auto Scheduling');
g_form.addOption(taskCategoryField, 'Forecasting', 'Forecasting');
g_form.addOption(taskCategoryField, 'Batch Jobs', 'Batch Jobs');
} else if (grpDisplay === 'Workforce Management - US') {
g_form.addOption(taskCategoryField, 'Configuration', 'Configuration');
g_form.addOption(taskCategoryField, 'Login', 'Login');
g_form.addOption(taskCategoryField, 'NSO', 'NSO');
g_form.addOption(taskCategoryField, 'SFTP - Global scape', 'SFTP - Global scape');
g_form.addOption(taskCategoryField, 'Access update', 'Access update');
g_form.addOption(taskCategoryField, 'Query', 'Query');
g_form.addOption(taskCategoryField, 'Terminate', 'Terminate');
g_form.addOption(taskCategoryField, 'Interface', 'Interface');
g_form.addOption(taskCategoryField, 'Timeclock', 'Timeclock');
g_form.addOption(taskCategoryField, 'Store close', 'Store close');
g_form.addOption(taskCategoryField, 'Schedule upload', 'Schedule upload');
g_form.addOption(taskCategoryField, 'Holiday', 'Holiday');
g_form.addOption(taskCategoryField, 'Reports - WFC', 'Reports - WFC');
g_form.addOption(taskCategoryField, 'Reports - WFAN', 'Reports - WFAN');
g_form.addOption(taskCategoryField, 'Automate', 'Automate');
g_form.addOption(taskCategoryField, 'Auto Scheduling', 'Auto Scheduling');
g_form.addOption(taskCategoryField, 'Forecasting', 'Forecasting');
g_form.addOption(taskCategoryField, 'Batch Jobs', 'Batch Jobs');
}
} else {
g_form.setDisplay(taskCategoryField, false);
}
g_form.setDisplay(taskCategoryField, true);
}
In this script, g_form.clearOptions('u_task_category') is used to remove all options from the Task Category field, and then the default 'None' option is added. Subsequently, based on the selected Assignment Group, specific options are added to the Task Category field.
If you found my response helpful, please mark it as āAccept as Solutionā and āHelpfulā. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/