how to get list of user in group in ui designer bonita 7.8.0?


i wont to get list of users in specific group and display in a select Widget in ui designer.
What type of API I want to use it?

1 answer



The following example can help you.
You should define a local variable and set list of student to it, then using external API in form designer, getting the variable and set it to select widget.

import org.bonitasoft.engine.identity.User
import org.bonitasoft.engine.profile.ProfileSearchDescriptor
import org.bonitasoft.engine.identity.GroupSearchDescriptor
import org.bonitasoft.engine.identity.UserSearchDescriptor

SearchOptionsBuilder s = new SearchOptionsBuilder(0, 1)
s.filter(GroupSearchDescriptor.NAME, "students")
Long groupId = apiAccessor.getIdentityAPI().searchGroups(s.done()).getResult().get(0).getId()

SearchOptionsBuilder s1 = new SearchOptionsBuilder(0, -1)
s1.filter(UserSearchDescriptor.GROUP_ID, groupId)

List studentList = new ArrayList()

for (User user: apiAccessor.getIdentityAPI().searchUsers(s1.done()).getResult()) {
Person t = new Person(user.getId(), user.getFirstName(), user.getLastName());



Submitted by antoine.mottier on Tue, 05/07/2019 - 09:22

Your solution is valid but you are duplicating information store in Bonita Engine database in a process variable that will itself been stored in the Bonita Engine database.

Instead I would recommend to declare a form variable initialized with a REST API call to the REST identity API. Then the REST API call result stored in the form variable can be mapped to the selected widget. This will prevent any duplication of the data in the database (it will be only temporary duplicated in the web browser memory).