- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 09:57 PM
The below onChange client script on "Assignment group" field will set the "Assigned to" field to the "Assignment group manager" and this is happening on only in native view, not in HR agent workspace.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
ScriptLoader.getScripts('sn_hr_core.utils_ui.jsdbx', function(){
getGlideRecord('sys_user_group',newValue , setAssignTo);
});
function setAssignTo(group){
if (group)
g_form.setValue('assigned_to', group.manager);
}
Why this behaviour required to assign to group manager instead of group members?
Thanks,
Sireesha.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 10:11 PM
Hi @jalipatisir ,
that should be because of the ScriptLoader
if you want this to work recreate the logic using GlideAjax and client callable script include
if your organization don't need it you can disable it.
Why this behaviour required to assign to group manager instead of group members?
Accountability and Ownership
- The group manager is typically responsible for overseeing the work of the group.
- Assigning the task to the manager ensures someone is accountable for triaging or reassigning the task appropriately.
Triage and Delegation
- Managers often act as triage points. They receive the task and then delegate it to the most appropriate team member.
- This is especially useful when the system cannot determine the best-suited member automatically.
Consistency Across Processes
- In many workflows, especially in HR or IT, assigning to the manager ensures a consistent entry point for handling requests.
Avoiding Random Assignment
- Without a clear rule, assigning to a random group member could lead to confusion or delays if the person is unavailable or not the right fit.
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 10:16 PM
script loader is not supported in workspace.
Since you mentioned it's an OOTB script then it means ServiceNow intended not to run this on workspace.
For making it work on the workspace you can create another onChange and use getReference with callback and ensure it runs only on workspace view
Uncheck Global checkbox and mention the workspace view name
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.clearValue('assigned_to');
}
var ref = g_form.getReference('assignment_group', callBackMethod);
}
function callBackMethod(ref) {
if (ref.manager)
g_form.setValue('assigned_to', ref.manager);
}
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
06-24-2025 10:11 PM
Hi @jalipatisir ,
that should be because of the ScriptLoader
if you want this to work recreate the logic using GlideAjax and client callable script include
if your organization don't need it you can disable it.
Why this behaviour required to assign to group manager instead of group members?
Accountability and Ownership
- The group manager is typically responsible for overseeing the work of the group.
- Assigning the task to the manager ensures someone is accountable for triaging or reassigning the task appropriately.
Triage and Delegation
- Managers often act as triage points. They receive the task and then delegate it to the most appropriate team member.
- This is especially useful when the system cannot determine the best-suited member automatically.
Consistency Across Processes
- In many workflows, especially in HR or IT, assigning to the manager ensures a consistent entry point for handling requests.
Avoiding Random Assignment
- Without a clear rule, assigning to a random group member could lead to confusion or delays if the person is unavailable or not the right fit.
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 10:16 PM
script loader is not supported in workspace.
Since you mentioned it's an OOTB script then it means ServiceNow intended not to run this on workspace.
For making it work on the workspace you can create another onChange and use getReference with callback and ensure it runs only on workspace view
Uncheck Global checkbox and mention the workspace view name
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.clearValue('assigned_to');
}
var ref = g_form.getReference('assignment_group', callBackMethod);
}
function callBackMethod(ref) {
if (ref.manager)
g_form.setValue('assigned_to', ref.manager);
}
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
06-25-2025 07:29 AM
Thanks for your suggestions!