How to retrieve Groups with filters

I have 30 groups in Bonita and I want to be able to retrieve groups that start with a string. The below code gets all groups and there is no way to filter. I dont have the group ids. 

IdentityAPI identity = apiAccessor.getIdentityAPI();
//
List<Group> groupNames = identity.getGroups(0, 40, GroupCriterion.NAME_ASC)

Hi,

You can filter the groups in groovy like this:

def identity = apiAccessor.getIdentityAPI(); // def groupNamesStartingWith = identity.getGroups(0, 40, GroupCriterion.NAME_ASC).findAll{ group -> group.name.startsWith('myNamePrefix') }

You can also use the Search function on the identity API like this:

def result = apiAccessor.identityAPI.searchGroups(new SearchOptionsBuilder(0, 99) .searchTerm('myNamePrefix') .done()).result

HTH
Romain

Thank you Romain. It worked