Populate EMail and phone of reference - reference via On change

RudhraKAM
Tera Guru

Can some one help me with the script 

 

As of now we have a reference field of sys_user_grmember where we are only populating one group users 

 

up on selecting the user we need to populate users email and phone , below is the script which is showing undefined, can some one help me where am I doing wrong?

 

 

RudhraKAM_0-1690164170621.png

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

  var user = g_form.getReference("project_commissioning_engineer", populateManager);
}
function populateManager(user) {
  g_form.setValue("project_commissioning_engineer_email", user.email);
 g_form.setValue("project_commissioning_engineer_phone", user.phone);	
	
   
}
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@RudhraKAM 

you should point your reference field to sys_user and not sys_user_grmember

then your script will work fine

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader