
- 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 10:05 AM
I will try this solution and let you know the outcome after I come back from my lunch break!
Thanks so much for your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 11:28 AM
Hi Archana,
I have everything in the script include but it still didn't work. Do I need to set the manager's variable field to a reference or leave as a single line text field?
Thanks,
Terry

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:07 PM
Yes, that is a solution that I'm looking for. The reason I'm struggling is that the manager email field is not a field that is available out of box so I'm trying to find a way somehow to pull this in from the user table as that manager would have a email address associated with their name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 12:18 PM
Thanks for clearing my doubts.
Am not sure if Script Include works for this or not. Lets go with onChange catalog client script.
Make sure you select correct Order Guide and set Variable name to YouruserField
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('mail',user.email);
g_form.setReadOnly('mail',true);
}}
Replace mail with mgr_email.
Hope this helps!
Thanks