Want to know how Can I know the users who is not a member of any group?

ahmed21
Kilo Expert

Hello ServiceNow community, I have a requirement to know who from the active users we have is not a member of a group with type "ITIL" (Type is an out of the box field on the group table.

we are on Helsinki Patch 11

Thanks a lot.

1 ACCEPTED SOLUTION

Hi Ahmed,




You can pull all users who are not mapped to any group using the following method.




1. Create a script include and place the below function in it.


script:


*************************


find_real_file.png



*****************************



2. Create a report on 'sys_user' table and call the script include function in the report filter. Please refer the below screenshot. On running the report, you'll get the list of users who are not member of any group.




find_real_file.png





Similarly, you can use the below script to fetch the list of users who are member of non ITIL type group.


find_real_file.png



-Udhay


Please Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

22 REPLIES 22

Once done   you can get the extract of Users from sys_user_grmember table get Unique value for Users & then go to User table & filter with User.Name is not one of (with the list of Unique users you got form sys_user_grmember table).



That in turn would suffice what is expected.


Kamal17
Kilo Sage

Hi Ahmed,



Navigate to Group Member list view using sys_user_grmember.list and then use the filter which i have highlighted in the below screenshot.


This will provide you the list of active users who are not members of ITIL type group.


find_real_file.png



-Udhay


Please Hit like, Helpful or Correct depending on the impact of the response


Thank you very much Udhay for your solution,


The group sys_user_grmember table contains users who already have a group, but my issue is to get the users who don't have a group or the group type is not itil


add this as a script include and amend your filter to sys ID is not javascript:findUsers()



findUsers();


function findUsers(){


var arr = [];


var gr = new GlideRecord("sys_user_grmember");


gr.query();


while(gr.next()) {


arr.push(gr.user.toString());


}


return arr;


}


Thanks, David,


I have tried this method and I have created the query (filter) on the sys_user table but it didn't work, it got me all the users on the user table. so I think their is something wrong.