- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2019 11:34 PM
Hi Experts, I need to get the records based on the following conditions/filters:
I want a filter option called “Assigned Manager” that shows Incidents where the User Reference entered is:
1. The Manager of a User in the Assigned_to field,
or
2. is the Manager of the Assignment group to which it was assigned.
---------> I had tried to the with following filters as
"Assigned_to.manager - is - gs.getUserID()"
or
"Assignment_group.manager - is - gs.getUserID()". - > but it get the records which are assigned to the current user.
Can you please share your thought to achieve this requirement.
Thanks in advance for your valuable thoughts
Thanks
Santhosh.K
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2019 11:45 PM
Hi there,
Have you tried using:
gs.getUser().getManagerID();
Also have a look at:
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2019 11:45 PM
Hi there,
Have you tried using:
gs.getUser().getManagerID();
Also have a look at:
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 12:03 AM
Thank you Mark, for your time
I tried in:
For Assigned_to.manager - is -
javascript:gs.getUser().getManagerName();
javascript:gs.getUser().getManagerID();
But no luck.
Do we have any other way/methods to get the required users.
Again Thanks..
Thanks
Santhosh.K

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 12:10 AM
Hi
i m checking purpose only so i wrote backgroud script so u can write before query business rule
var gr=new GlideRecord('incident');
gr.query();
while(gr.next())
{
gs.print(gr.assigned_to.manager.name+ " " +gr.assignment_group.manager.name);
}
Thanks,
Rahul Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 01:16 AM
Hi Santhosh,
Find below the code which fetches the active incidents when the given user is either a manager of the assigned_to field or group manager of the assignment group.
var referenceUser = 'a8f98bb0eb32010045e1a5115206fe3a';//replace this line with your user sys_id that you get. for now i have used static id here
//Now fetch the groups of this user where he is a manager of those groups.
var gr = new GlideRecord("sys_user_group");
gr.addQuery("manager",referenceUser);
gr.query();
var groups=[];
while(gr.next()) {
groups.push(gr.getValue("sys_id"));
}
gs.print("Group ids where he is manager is "+groups);
var gr=new GlideRecord("incident");
gr.addActiveQuery();
var q1 = gr.addQuery("assigned_to.manager",referenceUser);
q1.addOrCondition("assignment_group","IN",groups);
gr.query();
while(gr.next()) {
gs.print("Incidents are "+gr.getValue("number"));
//write your logic here
}
Mark the comment as a correct answer and also helpful once worked.