Details should be auto populate based on Requested For variable in Service Catalog Item?

srinivas snow21
Kilo Explorer

Hello 

I have three catalog variables in my service catalog item form.

Based on Requested For variable, Auto populate email and department .

How to achieve this requirement

 

I want achieve this through Script Include and Client Scripts.

Thanks in advanced

 

 

1 ACCEPTED SOLUTION

Robin Bakker
Kilo Guru

Hi,

Something like this should work. Create a catalog client script and give it the property of "OnChange" then select the onchange for the "requested for" field and put in the following script. 
Don't forget to put UI Type on "All"

g_form.getReference('requested_for', callBack); 
	function callBack(user){
		g_form.setValue('usr_department',user.department);
		g_form.setValue('usr_email',user.email);
	}
If my answer has helped with your question, please mark it as correct and helpful.

Kr!
Robin

View solution in original post

3 REPLIES 3

Anil Lande
Kilo Patron

Hi,

Please check below link:

https://community.servicenow.com/community?id=community_question&sys_id=01f17a2fdbe87414a4c10b55ca96...

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Robin Bakker
Kilo Guru

Hi,

Something like this should work. Create a catalog client script and give it the property of "OnChange" then select the onchange for the "requested for" field and put in the following script. 
Don't forget to put UI Type on "All"

g_form.getReference('requested_for', callBack); 
	function callBack(user){
		g_form.setValue('usr_department',user.department);
		g_form.setValue('usr_email',user.email);
	}
If my answer has helped with your question, please mark it as correct and helpful.

Kr!
Robin

christophenow
Tera Expert

The "new" right way to do this is to use the "Auto-populate" functionality available since Utah release.

In your variable form, you have a tab "Auto-populate" with 3 fields:

Dependent question : Choose the reference variable (in your case "Requestor")

Reference : filled automatically with the related table (in your case, sys_user)

Dot walk path : Choose the field that contains the value you want to populate (in your case, Requestor.Email for the Email variable for example)

 

More information here.

https://www.servicenow.com/community/developer-articles/auto-populate-a-variable-based-on-a-referenc...

 

No need to script anymore 😉

 

If usefull, please mark as helpful.