Catalog Item: How to populate other reference fields on a form based on the logged in user?

gjz1
Giga Expert

On my catalog form I have a requirement to populate the logged in user's department and location.

I have three variables on the form - requested_by, department, location - and all three are reference fields on the catalog form and on the sys_user table (department references cmn_department, location references cmn_location).  I get the requested_by to display without a problem but I don't seem to be able to populate the requested_by's department and location from the sys_user table in the other fields.  Any idea how I can do this in a catalog item form?  I can find a lot of information for other forms but nothing specific to a catalog item. 

Thanks in advance for your help.

 

 

12 REPLIES 12

Anurag Tripathi
Mega Patron
Mega Patron
Hi, Refer to the link below, it's pretty much doing the same thing. https://community.servicenow.com/community?id=community_question&sys_id=c2df3aaddb58dbc01dcaf3231f961994&view_source=searchResult Please mark my answer correct/helpful if it solves your issue. Thanks, Anurag
-Anurag

Shashikant Yada
Tera Guru

You can write Onload client script

var userdet= g_form.getReference('requested_by',getfields);
function getfields(userdet)
{

g_form.setValue('department',fac.department);


}

gjz1
Giga Expert

This is on an order guide, I don't see any option to create a script of any kind.

You may need to right click and choose configured > Related lists and then add Catalog client Script -> Catalog item if you do not see it on the form.