To get Workgroup Names without using any filter condition

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

I want to implement projection queries to fetch the workgroup name instead of the workgroup object by modifying the below lines of code

import sailpoint.object.Identity;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import java.util.List;
  
List wrkgmemnberList = new ArrayList();
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq("workgroup",Boolean.TRUE));
List<Identity> workGroups = context.getObjects(Identity.class,qo);
for(Identity ident : workGroups)
{
	System.out.println("Workgroup name - "+ident.getName()+"\nMembers");
	Identity workgroup = context.getObjectByName(Identity.class, ident.getName());
    if(workgroup.isWorkgroup())
    {
      Iterator wrkGrpmembers = ObjectUtil.getWorkgroupMembers(context, workgroup, null);
      while(wrkGrpmembers.hasNext())
      {		
        Object[] object = (Object[]) wrkGrpmembers.next();
        Identity ids = (Identity) object[0];
        wrkgmemnberList.add(ids.getName());  
        System.out.println(ids.getName()+" - "+ids.isInactive());
      }	
    }
}

code to get workgroup names only.

List wrkgNames = new ArrayList();
  QueryOptions qo = new QueryOptions();
  qo.addFilter(Filter.eq("workgroup",Boolean.TRUE));

  List props = new ArrayList();
  props.add("name");
  Iterator it = context.search(Identity.class, qo, props);

  while (it.hasNext()) {
    String name = (String)((Object[])it.next())[0];
    wrkgNames.add(name);
  }

  return wrkgNames;

The code which I have provided is using the projection search , its not storing the workgroup object. its just pulling the name of workgroup from the database and storing in this and then returning.

Iterator it = context.search(Identity.class, qo, props);

The method search(java.lang.Class<T> cls, QueryOptions options, java.util.List<java.lang.String> properties)

Performs a projection search for selected object properties and return an iterator.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.