Find number of group members that have a specified role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 01:29 PM
I am looking for assistance how I can create a script that will show us the number of users who are part of a specific sys_user_group who have a sys_user_role.
groups does not appear to be a filterable field for sys_user, so I feel that a custom script is my only way of handling this.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 01:33 PM
Hello,
Where are you running this script?
Unfortunately, you didn't provide many details in that regard.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 11:30 AM
I actually have not yet created the script. I've opened this question for tips on where i should begin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 01:40 PM
Group membership is a many-to-many table called sys_user_grmember.
Below link has an example that might help.
https://community.servicenow.com/community?id=community_question&sys_id=621c8581db2edf0054250b55ca9619a7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 04:15 PM