Catalog Item: How to populate other reference fields on a form based on the logged in user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2018 12:08 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2018 02:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2018 02:49 AM
Hi,
try below on change client scrip-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = g_form.getReference('requested_for',callBack);
}
function callBack(gr){
g_form.setValue('approvers',gr.manager);
g_form.setValue('phone_number',gr.mobile_number);
g_form.setValue('email',gr.email);
g_form.setValue('location',gr.location);
g_form.setValue('employee_number',gr.employee_number);
g_form.setValue('cost_center',gr.cost_center);
g_form.setValue('country',gr.country);
g_form.setValue('company_code',gr.company);
}
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2018 09:42 AM
It has to be easier than creating a client script. In my developer instance with demo data there is a record producer that has two reference variables: the first gets a group and the second gets the members of the group selected in the first variable and both use a reference qualifier. Unfortunately I'm not able to find the code used by the reference qualifier to copy it. Why would I need to create a client script when the OOB demo data does the same thing I want with a reference qualifier?
Demo data:
Record Producer = Grant Role Delegation Rights within a group with just two variables - group and user, both reference variables. Selecting the group limits the users.
Group field:
User field:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2018 09:49 AM
this is a business rule
NAme : Role Delegation Functions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2018 09:50 AM
https://<your instance id>.service-now.com/sys_script.do?sys_id=0149c9930a0a0b300041ce2777564999&sysparm_record_target=sys_script&sysparm_record_row=1&sysparm_record_rows=1&sysparm_record_list=nameCONTAINSDele%5EscriptCONTAINSgetRoleDelegatorGroupOptions%5EORDERBYname