Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to auto populate assignment group using assigned to user reference table by using client script

SRAMIKA
Tera Contributor

ihello,

 “assigned to” is a reference with the "sys_user" table needs to  populate the group name in the "assignment groups" where the reference is "sys_user_group". need a onchange() script without using scriptinclude.

give me input on how to do using on change() client script.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   var user= new GlideRecord('sys_user');
   user.addQuery('name','');
   user.query();

  if(user.next()){
    var groupname= user.getValue('name');
   
    g_form.setValue('u_assignment_group',groupname);
  }
else{
    g_form.setValue('u_assignment_group','');
}
   
   //Type appropriate comment here, and begin script below
   
}

 

1 REPLY 1

DanielCordick
Mega Patron
Mega Patron

The issue with this approach is, a user could be in many groups, how do you know which group to pick? Tickets are usually assigned to a group first and then picked up from any user in the group. What is the use case to have it assigned to a person before a group?