Fields should be autopopulate based on requested for user.

Atchutaram
Tera Contributor

Hi Experts,

Good Day!

                      I am creating a new catalog item, in that i have created a variable reference type which is Requested for and it fetches the user full name.

The catalog item has other variables like first name , last name, employee Id, employee email, work-phone, these fields should be auto-populated based on change of requested for.

 

Could you please suggest me how can i do this.

 

Best Regards,

Atchutaram.

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

You can write a on change catalog client script with the below code:-

 

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

	g_form.getReference('requested_for', callBack); 
	function callBack(user){
		g_form.setValue('firstnamevariable',user.first_name);
		g_form.setValue('lastnamevariable',user.last_name);
               g_form.setValue('emailvariable',user.email);
	}
}

 

Please mark my answer as correct based on Impact.

View solution in original post

2 REPLIES 2

kamlesh kjmar
Mega Sage
Mega Sage

Hi @Atchutaram 

 

Try the below link : 

 

https://www.servicenow.com/community/it-service-management-forum/details-should-be-auto-populate-bas...

 

 

I hope this help.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

You can write a on change catalog client script with the below code:-

 

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

	g_form.getReference('requested_for', callBack); 
	function callBack(user){
		g_form.setValue('firstnamevariable',user.first_name);
		g_form.setValue('lastnamevariable',user.last_name);
               g_form.setValue('emailvariable',user.email);
	}
}

 

Please mark my answer as correct based on Impact.