- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 05:37 AM
Im trying to create a cusom dynamic filter to show only the incidents that Assignment group is one of user's groups (without parent group).
For some reason it only shows me one group among the groups that i belong to.
I can only see the incidents of one of my groups instead of the two of them:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:00 AM
Hi @Alon Grod,
Then it probably is OOTB in some plugin installed in my instance.
This is the underlying code, which you can use:
/**
Default filter "One of My Groups - d6435e965f510100a9ad2572f2b47744" includes parent groups too
As per defect "DEF0173629" we want only groups the user is part of not parent groups
*/
getGroupsIAmMemberOfExcludeParents: function(userId) {
var groups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group.active', true);
gr.query();
while (gr.next()) {
var groupId = gr.getValue('group');
if (!gs.nil((groupId)))
groups.push(groupId);
}
return groups;
},
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:22 AM
Hi @Alon Grod,
No need to use javascript: int the script field here just use (assuming you are not changing the script include name you already have, and will use this script I sent you)
new getGroups().getGroupsIAmMemberOfExcludeParents(gs.getUserID());
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 07:55 AM
@Peter Bodelier hi, i dont have this dynamic OOTB filter. I only have 'One of my groups' which also return the 'Parent' group of the current group and its not helpful. I only need to user's groups without the parent

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:00 AM
Hi @Alon Grod,
Then it probably is OOTB in some plugin installed in my instance.
This is the underlying code, which you can use:
/**
Default filter "One of My Groups - d6435e965f510100a9ad2572f2b47744" includes parent groups too
As per defect "DEF0173629" we want only groups the user is part of not parent groups
*/
getGroupsIAmMemberOfExcludeParents: function(userId) {
var groups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group.active', true);
gr.query();
while (gr.next()) {
var groupId = gr.getValue('group');
if (!gs.nil((groupId)))
groups.push(groupId);
}
return groups;
},
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:10 AM
@Peter Bodelier hi but what is the difference between what you sent to what i did?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:15 AM
There is very little difference indeed. But what I sent you is created by ServiceNow, and I verified that it is working as per your requirement as well.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:17 AM