Removing users from a group

prernabhandari
ServiceNow Employee
ServiceNow Employee

Hello All.

I have a requirement where I need to remove around 100 users from the a group. The Only way I know is editing the group Members/editing a   collection list.

This becomes a manual process. Is there any other method I can use? I am thinking in lines of a fix script.

TIA

Prerna

10 REPLIES 10

Deepak Ingale1
Mega Sage

Hi Prerna



1) If request is generated for this in system via service catalog, where you will have a list of users in list collector variable, this can be used to automate the process



2) If you just simply have a XLS or CSV file via which you want to do it, i would suggest manual operation is the best way to achieve this.


Hey Deepak,


All I have is a CSV file. But manually removing around 100 users doesn't sound efficient.


Also I need to add these users to a new group now. I was thinking a script where I change the associated field to point to a new group than old group


Hi Prerna,



User membership to groups is stored in ServiceNow in m2m table "sys_user_grmember"



Things we are trying to achieve would have been best possible to do via "service request" wherein we will have a variable of reference type pointing toward sys_user_group table and other variable of list collector type pointing towards sys_user table. In that way, we could have written a script by using sys_ids of users and groups which are unique in system.



Now in your case, this totally depends on how your XLS sheet is given to you and its reliability, validity of data in it. This can still be possible by using import set scripting but your xls sheet must have some unique identifier for each record in it like group and user using which this can be done.