- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2022 06:07 AM
Heya!
I'm trying to set the default value of a reference variable on a catalog item. The reference variable is referencing users with a certain role in our organization, leaders/managers have this role.
I've tried gs.getUser().getManagerID() but I get no value? I can confirm that the user has a manager.
Thanks,
goller
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2022 06:15 AM - edited ‎10-20-2022 06:16 AM
Hi @goller
If you are doing this in scoped application it will not work.
Instead you can use below:
javascript: var loggedinManager;
var gr=new GlideRecord("sys_user");
gr.get(gs.getUserID());
loggedinManager=gr.manager.toString();
loggedinManager;
Hope it helps
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2022 06:22 AM
Hi @goller
You need to create a Script Include 'UserManagerID' and function 'getManager()'. Please find the code of this function below:
getManager: function() {
var manager;
var grUser = new GlideRecord('sys_user');
if (grUser.get(gs.getUserID())) {
var manager = grUser.manager;
}
return manager;
},
Now use below link in your Default value of Reference Variable:
javascript: new UserManagerID().getManager();
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023