Find number of group members that have a specified role

Nicholas Cerill
ServiceNow Employee
ServiceNow Employee

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. 

 

7 REPLIES 7

Allen Andreas
Administrator
Administrator

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!

I actually have not yet created the script. I've opened this question for tips on where i should begin

Jeff Geiger
ServiceNow Employee
ServiceNow Employee

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

Hitoshi Ozawa
Giga Sage
Giga Sage

As Jeff replied, group membership is saved in sys_user_grmember table. There is no need to write a script to list users in a specified group. Just set a filter on group.

To access sys_user_grmember, enter "sys_user_grmember.list" in Filter Navigator.

find_real_file.png