Visible Task category field based on Assignment group type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Hi Everyone,
I have one requirement on Catalog task Form.
Assignment group is there and it is reference type and having the groups are Workforce Management-APAC, Workforce Management-US, Workforce Management-EU and there is another field is Task Category filed and type is String and having the option Configuration, login, NSO,Query.If i select any one assignment group in Workforce Management-APAC/EU/US Then only these 4 option visible in Task Category field in Catalog task form .provide solution to this one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday - last edited Wednesday
Hi @Manohararuna ,
You need to write the Client script -
Table: sc_task (Catalog Task)
Type: onChange
Field Name: assignment_group
UI Type: Desktop
When to run: onChange
Code: -
var groupName = g_form.getDisplayValue('assignment_group');
// Always clear old options
g_form.clearOptions('u_task_category');
// Add a default 'None' option
g_form.addOption('u_task_category', '', '-- None --');
// Apply conditional logic
if (groupName === 'Workforce Management - APAC') {
g_form.addOption('u_task_category', 'Configuration', 'Configuration');
g_form.addOption('u_task_category', 'Login', 'Login');
} else if (groupName === 'Workforce Management - EU') {
g_form.addOption('u_task_category', 'NSO', 'NSO');
g_form.addOption('u_task_category', 'Query', 'Query');
} else if (groupName === 'Workforce Management - US') {
g_form.addOption('u_task_category', 'Login', 'Login');
g_form.addOption('u_task_category', 'Query', 'Query');
g_form.addOption('u_task_category', 'Configuration', 'Configuration');
} else {
// For all other groups, hide the field and exit
g_form.setDisplay('u_task_category', false);
}
// Show the field if a valid group is selected
g_form.setDisplay('u_task_category', true);
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Hello Naval Singh,
need small correction on your script. Because i have few more option also there in Task category field . But only above mentioned options only visible when i could select the particular assignment group.
like if i select assignment group as Workforce Management - APAC then after in Task Category field visible only Configuration
Login
Query
NSO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday - last edited Wednesday
Hi @Manohararuna ,
The above shared client script is just for your understanding, you can change it as per your requirement. if you want me to correct it, please share all details.
I will be happy to answer that one!!
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
it's an easy requirement using onChange client script on Assignment Group field.
you can use addOption() and removeOption()
what did you start with and where are you stuck?
💡 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