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

Dubz
Mega Sage

Hi Ahmed,



You can create a script include like below and then either apply it in a filter condition on the user table or on a report or create an application menu with this as a condition.



Make sure the script include is called findUsers and is client callable. call it in a filter by saying Sys ID = javascript:findUsers()



findUsers();


function findUsers(){


var arr = [];


var gr = new GlideRecord("sys_user");


gr.addQuery('roles!=itil');


gr.query();


while (gr.next()) {


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


}


return arr;


}


Hello Dave,


I have tried to create the script includes and the report but it didn't work, I think there is something wrong with it.


Jaspal Singh
Mega Patron
Mega Patron

Hi Ahmed,



You can also give a look for table sys_user_grmember table. All you need is to type sys_user_grmember.LIST in application navigator & add necessary Group, Name, Type as required.


Thank you Japal,


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