How to retrieve Groups with filters

1
0
-1

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 groupNames = identity.getGroups(0, 40, GroupCriterion.NAME_ASC)

1 answer

1
0
-1
This one is the BEST answer!

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

Comments

Submitted by habdulmalak_2529287 on Thu, 02/09/2023 - 12:31

<p>Thank you Romain. It worked</p>

Notifications