How to check initiator role on gateway path condition

1
0
-1

Hi, I'm looking for a way, if it is possible at all in Bonita 7.10, to choose a path on a gateway based on the role in my organization of the initiator of the process.

Example:

- Initiator is a Sales Assistant i need to follow path A

- Initiator is Sales Manager i need to follow path B

Thanks

1 answer

1
0
-1
This one is the BEST answer!

hello,

On the branch of the gateway, i imagine you can use a condition expression close to this one:

import org.bonitasoft.engine.identity.User
import org.bonitasoft.engine.identity.UserSearchDescriptor
import org.bonitasoft.engine.search.SearchOptionsBuilder

User Initiator = BonitaUsers.getProcessInstanceInitiator(apiAccessor,processInstanceId);

Long roleId = apiAccessor.getIdentityAPI().getRoleByName("Sales Assistant").getId();

final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 1);
builder.filter(UserSearchDescriptor.ROLE_ID, roleId);
builder.filter(UserSearchDescriptor.USER_NAME, Initiator.getUserName());

return apiAccessor.getIdentityAPI().searchUsers(builder.done()).getCount() == 1 ;

Need to be careful, if the user has both role, you will need a default path.

hope this helps,

Julien.

Notifications