Clear all members of workgroup

Hi,

I am trying to write a rule to clear all members of a list of groups.
Seems workgroup is treated as identity.
I could not find any API to remove all users.

Also if I try to find all member of specific workgroup, then I am not sure what filter I can use.

Something like this


qo1.addFilter(Filter.like("email","@ascension.org",Filter.MatchMode.END));
		List users1 = context.getObjects(Identity.class, qo1);

I don’t think there is any method to remove all users, you will have to iterate through the workgroup members and then remove them one by one.

To get all members of a workgroup you can use the getWorkgroupMembers method available in ObjectUtil

import sailpoint.object.Identity;
		import sailpoint.api.ObjectUtil;
		Identity workgroupObj=context.getObjectById(Identity.class, workgroupName);
		List workgrpMembers=new ArrayList();
		List props = new ArrayList();
		props.add("name");
		Iterator itr=ObjectUtil.getWorkgroupMembers(context, workgroupObj,  props);
		while(itr.hasNext()){
			Object[] newList= (Object[])itr.next();
			workgrpMembers.add(newList[0]);
			log.debug("Current item is ------------"+newList[0]);
        }

The workgroup membership is applied on member identity and hence you will need to update the member identity to remove workgroup from each member.

If you need to Clear all the users from the groups, just delete the workgroups and recreate it.

Simple as that.;