- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-26-2019 02:21 PM
ServiceNow provides a wonderful dynamic filter that you can use to filter lists which have a reference field to the sys_user_group table. If you belong to multiple groups, this will filter the list on all of them:
That said, I have a manager who periodically needs to filter lists ( incidents, change requests, etc ) for all the groups to which another person belongs. This was a tedious process of looking at the person's profile and making a list of groups and then creating a series of "group=" matches linked with "or".
I was able to implement this function to work almost as easily as the dynamic filter. But it is a script call to a function contained in a business rule named "groups, banners". This business rule contains several functions which help with various scripting and filtering duties. The script code that I added is this:
function getGroupsFor(user_id) {
var ourUser = gs.getUser();
var newUser = ourUser.getUserByID(user_id);
return newUser.getMyGroups();
}
I also created a dynamic filter entry, but later on deactivated it. So I don't think a dynamic filter option is needed.
To invoke the filter, use a string like this in the query of a group:
javascript:getGroupsFor('user_id')
The "user_id" text is replaced with the target user's User ID ( user_name). For example, a person with a User ID of "luddy" would result in : javascript:getGroupsFor('luddy')
In context:
- 1,747 Views