
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 07:23 AM
We are trying to create a catalog item variable to display the list of users that are managers. Is there a build in variable type that will let me create a reference for the managers field?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 08:57 AM
If it is as easy as you make it sound please feel free to correct me. I'm a relatively new ServiceNow admin. I don't see a simple solution to only showing users that are listed as a manager. I looked into how advanced conditions work and ended up making a script include that returns a distinct list of sys_ids from the manager column on sys_user.
In the advance qualifier:
javascript:getListOfManagers();
Script include:
function getListOfManagers() {
var mgr_sys_ids = [];
var gr = new GlideAggregate('sys_user');
gr.groupBy('manager');
gr.query();
while (gr.next()) {
mgr_sys_ids.push(gr.manager.sys_id);
}
return 'sys_idIN' + mgr_sys_ids.join(",");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 07:26 AM
Hello Ryan,
Nothing OOTB. You can do this via Reference qualifier.
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 08:57 AM
If it is as easy as you make it sound please feel free to correct me. I'm a relatively new ServiceNow admin. I don't see a simple solution to only showing users that are listed as a manager. I looked into how advanced conditions work and ended up making a script include that returns a distinct list of sys_ids from the manager column on sys_user.
In the advance qualifier:
javascript:getListOfManagers();
Script include:
function getListOfManagers() {
var mgr_sys_ids = [];
var gr = new GlideAggregate('sys_user');
gr.groupBy('manager');
gr.query();
while (gr.next()) {
mgr_sys_ids.push(gr.manager.sys_id);
}
return 'sys_idIN' + mgr_sys_ids.join(",");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 09:54 AM
Hello Ryan,
Yes, you are right. You need a script include that returns a sys_ids of manager. Please feel free to share the script in case it is not working.
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 10:18 AM
It's working great, thanks for pointing me in the right direction. I edited my previous reply with the code.