Retrieve group IDs

To find all groups in an organization, you can use the findGroups() method.
Before you begin:

Retrieve the groupName string for the name of the group in the locale that you are using.

  1. Invoke findGroups(). By default, all groups use organizationId = 0. To retrieve a group that uses different organization ID specify the organizationId integer for the organization.
    int organizationId = 0;
    FindGroupsResult result=coreWebService.findGroups(organizationId, locale);
  2. Check the result for errors and handle any errors.
    if (result.getFindGroupsReturnStatus().getCode() != FindGroupsReturnStatusEnumType.SUCCESS) 
    {    
          // handle any errors    
    }
  3. Loop through the result until you find the group that you want.
    for (Group itr:result.getGroups()) 
    {
        if(itr.getLocaleNameAndDescription().getName().equals(groupName)
        {
            return itr.getGroupId();
        }
    }
Previous topic: Managing groups

Was this information helpful? Send us your comments.