I think actor and actor filter need a little bit of clarification.
Actor and actor filters are two alternatives to define who can perform a task. Several users might be able to perform one task. In order to avoid concurrent access to execute a task, a user can claim and release a task in the Bonita portal.
Now what is the difference between actor and actor filter:
Actor: in the process definition an actor is just a name associate with a lane or directly with a task. In process configuration you will then associate this actor with group(s), role(s), membership(s), user(s) or any combinations of all the previous in order to define who can do the task. Configuration of the actor is only based on organization (users, roles, groups) information. It cannot use process information such as a process business data or information about the user who start the process.
Actor filter: first this is really a bad name as it actually does not filter anything. Actor filter is another solution to create a list of users who can do a task. This list of user will be compute by executing an actor filter when the task is reached. An actor filter can have inputs and is executed when the process instance is running. So an actor filter can use information such as process business variable, process instance initiator (the user who start the process)… Actor filter is for example useful if you want to assign a task to the manager of the user who start a process instance. You have a catalog of actor filters available out of the box and you can also create your own one.
In your situation, as you want to associate your task to users only based on roles and groups information, actor option should do the trick.
Let me know if this is not perfectly clear for you.
List memberships = apiAccessor.identityAPI.getUserMemberships(userId,0,1,
UserMembershipCriterion.ASSIGNED_DATE_ASC);
Long groupId;
if(memberships!=null && memberships.size()>0) {
groupId = memberships[0].getGroupId()
}
//manager is a example on get role by name change it with your role name
long specificRoleId=apiAccessor.identityAPI.getRoleByName(“manager”).getId();
final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 100);
builder.filter(UserSearchDescriptor.GROUP_ID, groupId);
builder.filter(UserSearchDescriptor.ROLE_ID, specificRoleId);
final SearchResult userResults = apiAccessor.identityAPI.searchUsers(builder.done());
List reviewerList = new ArrayList();
for(User user:userResults.getResult()){
reviewerList.add(user.getId())
Thanks for your help. I thought I was not clear about the concept. This is really helpful to me.
I realized that I need to change the question.
For example, I would like to change the question.
Is it possible to get a manager’s id from grouplist?
From group name, is it possible to get a manager’s id from each group?
import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.User;
IdentityAPI identity = apiAccessor.getIdentityAPI();
User user = identity.getUserByUserName(groups);
return user.getId();
Thanks for the comment.
I would like to explain my situation.
I am modifying a task done by the other person.
In UI form, a user selects groups, put request and upload files, then submit the task.
The selected group returned group names, then, I stored them into groups.
The original code sends the userName by pure JSON.
I would like to store manager’s ids and send or set Actor as a manager from selected groups.
I need to get manager’s name in UI form or need to get the manager’s list in actor groovy script as I write the code.
Yes. it is correct.
In the first task, a user selects one or many groups. The return value is groupName
The second task should be taken by managers of selected groups.
I can solve this using by database connector and retrieve the group name and manager name in the task,
However, I would like to solve the issue with actor filter configuration.
In Actor filter of the second task, set the users with a groovy script as managers of groups.
Is it the right way to approach the issue?
Thanks a lot.
I create an example of custom connector that I think do what you are looking for. An example of process is available as well. You can get it from GitHub: https://github.com/Bonitasoft-Community/custom-actor-filter-group-manager
Thanks for providing the example.
However, I could not download the latest release bos file from the github.
Would you update the final version of the release, please?
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.