How to set actor filter with group name and role name ?
I would like to get a user list with specific membership.
I created department bdm and stored department name.
I would like to set Actors with specific group users with a specific role.
variable stored selected groups by a user.
Actor filter has a script as follows :
In this code is username.
However, I would like to send group names in variable.
import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.User;
IdentityAPI identity = apiAccessor.getIdentityAPI();
User user = identity.getUserByUserName(group);
return user.getId();
Would you help me to get users list with specific group and role ?
Hi,
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.
Regards
Comments
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.
I hope this works for understanding.
Thanks in advance,
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.
Thanks for your help.
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.
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?
Thanks in advance.
Does this expire?
Comments
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserMembership;
import org.bonitasoft.engine.identity.UserMembershipCriterion;
import org.bonitasoft.engine.identity.UserSearchDescriptor;
import org.bonitasoft.engine.search.SearchOptionsBuilder
import org.bonitasoft.engine.search.SearchResult;
List<UserMembership> 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<User> userResults = apiAccessor.identityAPI.searchUsers(builder.done());
List<Long> reviewerList = new ArrayList<Long>();
for(User user:userResults.getResult()){
reviewerList.add(user.getId())
}
return reviewerList
I hope this will help ,
best regards
Thanks for your help.
It helps a lot to me.
Then, I realized that I need to change the question.
Is it possible to get a manager's id from groupName?
From group name, is it possible to get a manager's id from each group?