
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 08:32 AM
Hello All,
I am trying to find a easy and good solution to populate the manager's email address of a user from the sys_user table in a custom variable field for a service catalog item. The name of the variable field is "mgr_email" and I want to pull the manager's e-mail address in this field. I am currently working on an order guide for Onboarding/Offboarding so this is one of the business requirements on the catalog items attached to it.
I have tried various solutions on the community but none seem to work properly or there are so many examples that it overwhelms you to which one should be the right answer.
Any help or assistance would greatly be appreciated.
Thanks,
Terry
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:23 PM
Will I need to keep the default value under my variable name still that you provided earlier?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:27 PM
No. Whatever we have done so far is not needed. Just creating the above client script does your work.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:42 PM
Okay so I have the catalog client script in but it is not pulling this info over. Could it be that my user field is a custom field that is not included in the script?
All the other info in the other catalog client script that I already had in the order guide is pulling the info over without any issues.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:44 PM
Can you please share the snapshot of whole client script as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:48 PM
This is the one that I have been using since our Onboarding has been live in the production environment.
function onChange(control, oldValue, newValue, isLoading) {
var employeeName = g_form.getReference(control.name, function(user){
//This will set the value of the fields on the OnBoarding describe needs page
g_form.setValue('u_ob_employee_userid', user.user_name);
g_form.setValue('u_ob_employee_firstname', user.first_name);
g_form.setValue('u_ob_employee_lastname', user.last_name);
g_form.setValue('u_ob_employee_jobtitle', user.title);
g_form.setValue('u_ob_employee_costcenter', user.cost_center);
g_form.setValue('u_ob_employee_location', user.location);
});
}
Here is the additional catalog client script that I created from what you provided me earlier:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',newValue);
user.query();
if(user.next())
{
var man = user.manager;
user.get(man);
g_form.setValue('u_ob_employee_mgr_email',user.email);
g_form.setReadOnly('u_ob_employee_mgr_email',true);
}}