Create an exclusive gateway according group

Hi,

I need to create an exclusive gateway according group, i.e,
if (the user belong to “production group”) ==> get an specific way
else ==> just get the default way.

I don’t know how to get an attribute from the active user neither to take it and use it as a condition in a gateway.

Can someone help me please?

Hi.

I did this in a process to use the role of a user in a gateway.

First, I get the initiator id with this code in the Operations tab of a task :

return apiAccessor.getProcessAPI().getProcessInstance(processInstanceId).getStartedBy();

After that, I place my gateway. And for each flow, I use this code as condition :
(I change the role name for each flow)

import org.bonitasoft.engine.identity.Role; import org.bonitasoft.engine.identity.User; import org.bonitasoft.engine.identity.UserCriterion;

Role role = apiAccessor.getIdentityAPI().getRoleByName(“My role”);
int nb = (int) apiAccessor.getIdentityAPI().getNumberOfUsersInRole(role.getId());
List list = apiAccessor.getIdentityAPI().getUsersInRole(role.getId(), 0, nb, UserCriterion.USER_NAME_ASC);

User initiator = apiAccessor.getIdentityAPI().getUser(initiatorId);

if (list.contains(initiator)) return true;
return false;

You can do the same for groups by replacing the role by a group.

Thank you so much, my solution was:

import org.bonitasoft.engine.identity.UserMembership;
import org.bonitasoft.engine.identity.UserMembershipCriterion;

Boolean flag = false;

List listMemberships = apiAccessor.getIdentityAPI().getUserMemberships(BonitaUsers.getUser(apiAccessor,taskAssigneeId).getId(), 0, 100, UserMembershipCriterion.ASSIGNED_DATE_ASC);
List listGroups = new ArrayList();
for (UserMembership userMembership : listMemberships){

if(userMembership.getGroupName().equals(“Topografia”) || userMembership.getGroupName().equals(“Obra”) || userMembership.getGroupName().equals(“Presupuestos”)){
flag=true;
}
}
return flag;