
- 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 09:53 AM
Vivek,
Yes, we have on the first page of the order guide where the manager will select a user from the reference and from there I want it to pull that users manager's email.
Thanks,
Terry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 09:16 AM
Hi Terry,
Create a Script Include named getEmail as below. Make sure the pre-populated script in script include is erased and paste it there.
function getEmail()
{
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',gs.getUserID());
user.query();
if(user.next())
{
var man = user.manager;
return man.email;
}
}
Set default value of mgr_email variable to javascript:getEmail()
The above script works if you are trying to get Logged-in user's manager email. Let me know if I somehow misunderstood the question.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 09:55 AM
Hi Archana,
Thanks for your reply as well.
I'm not trying to get the logged-in users manager but I am trying to get the user selected on the referenced field manager.
For example if I have a variable "Who is it for?", I would want to pull that user's manager that is in this field on the order guide.
Thanks,
Terry Carter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 09:56 AM
I meant that manager's email address and populate it on the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 10:01 AM
Just few updates to the above post by which I feel we can achieve this requirement.
function getEmail(gr)
{
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',gr);
user.query();
if(user.next())
{
var man = user.manager;
return man.email;
}
}
Default Value:javascript:getEmail(current.variables.VARIABLENAME);
Hope this helps!
Thanks