How to auto populate assignment group and assigned to based on caller

Alon Grod
Tera Expert

Hi,

 How to write on change client script to auto populate assignment group and assigned to based on caller on incident table. 

1 ACCEPTED SOLUTION

@Alon Grod write an on change client script on called ID field and call a script include using glide ajax like below

Make sure your script include name is getStandardFields

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue == '') {


  return;


  }



  //Type appropriate comment here, and begin script below








  var ga = new GlideAjax('getStandardFields');//this is the script include


  ga.addParam("sysparm_name", "getFields"); //this is the function within the script include


  ga.addParam("sysparm_std", newValue);


  ga.getXML(getResponse);


}



function getResponse(response) {


  var values = response.responseXML.documentElement.getAttribute('answer');


  g_form.setValue('assignment_group', values);





}

 

Script include :

 

Script Include: (Ensure the client callable checkbox is checked)



var getStandardFields = Class.create();


getStandardFields.prototype = {


  getFields : function() {


  var std = this.getParameter('sysparm_std');


  var standardFields = new GlideRecord('sys_user_grmember');

standardFields.orderBy('sys_created_on');
  standardFields.addQuery('user', std);


  standardFields.query();



  if(standardFields.next()) {


  return standardFields.group.toString();


  }





  },


  type: 'getStandardFields'


};

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks

View solution in original post

7 REPLIES 7

Mohith Devatte
Tera Sage
Tera Sage

Hello @Alon Grod ,

so when you select caller you need to populate assignment group and assigned to ?

if yes whats the criteria to populate do you have any specific group and user ?

@Mohith Devatte its based on the first group that the user belong to from the sys_user_group table

@Alon Grod write an on change client script on called ID field and call a script include using glide ajax like below

Make sure your script include name is getStandardFields

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue == '') {


  return;


  }



  //Type appropriate comment here, and begin script below








  var ga = new GlideAjax('getStandardFields');//this is the script include


  ga.addParam("sysparm_name", "getFields"); //this is the function within the script include


  ga.addParam("sysparm_std", newValue);


  ga.getXML(getResponse);


}



function getResponse(response) {


  var values = response.responseXML.documentElement.getAttribute('answer');


  g_form.setValue('assignment_group', values);





}

 

Script include :

 

Script Include: (Ensure the client callable checkbox is checked)



var getStandardFields = Class.create();


getStandardFields.prototype = {


  getFields : function() {


  var std = this.getParameter('sysparm_std');


  var standardFields = new GlideRecord('sys_user_grmember');

standardFields.orderBy('sys_created_on');
  standardFields.addQuery('user', std);


  standardFields.query();



  if(standardFields.next()) {


  return standardFields.group.toString();


  }





  },


  type: 'getStandardFields'


};

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks

Hardik2109
Tera Guru