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.

auto populate email id when name is selected from the reference field(sys_user)

Sneha39
Mega Guru

auto populate email id when name is selected from the reference field(sys_user)

Form fields

Name(reference from sys_user)

email( to be populate)

tried client script on variable set but its not working,

 

Kindly help with this simple script.

 

Thanks

1 ACCEPTED SOLUTION

dvp
Mega Sage

Here is an onChange catalog client script

Please update the variable names in the below script

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


   var usr = g_form.getReference('USER_VARIABLE_NAME', callBack);
	
}

function callBack(usr)
{

	g_form.setValue('EMAIL_VARIABLE_NAME', usr.email);


}

View solution in original post

10 REPLIES 10

Eswar11
Mega Contributor

Sneha, 

why are you using script , when you can use dot walking without script. please let me know if this did not help you .

https://docs.servicenow.com/bundle/london-platform-user-interface/page/use/navigation/reference/dot-walking-examples.html