- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hello All,
Could someone assist with the following requirement?
I’m working with the Request Delegate catalog item. The goal is to allow line managers to request delegates for the direct reports of their direct reports (i.e., two levels down in the org chart).
If a manager impersonates and opens this catalog item, they should only see their direct reportees and second-level reportees (i.e., the reportees of their reportees) in the "Requested For" variable on the portal.
Can anyone suggest how to implement this functionality?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
you can use advanced ref qualifier with this
something like this
javascript: var query = '';
var userId = gs.getUserID();
var users = [];
// Direct reports
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', userId);
gr.query();
while (gr.next()) {
users.push(gr.getUniqueValue());
}
// Second-level reports
if (users.length > 0) {
var gr2 = new GlideRecord('sys_user');
gr2.addQuery('manager', 'IN', users.join(','));
gr2.query();
while (gr2.next()) {
users.push(gr2.getUniqueValue());
}
}
query = 'sys_idIN' + users.toString(); // list of user sys_ids
query;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@Ankur Bawiskar : It's working now, it was a typo in my script.