How to check initiator user role during human tasks

1
0
-1

Hi, I need to know if is it possible (Bonita 7.10) to check the initiator user role in order to take different paths during the flow execution.

I mean:
- The first human task of the flow is triggered by a user that submit a set of data then
- If the initiator user has role A flow goes to path A
- If the initiator user has role B flow goes to path B

In my case I have a situation where depending on user role of the first task, the second human task of the flow must be taken by different users (by role)

First human task => Second human task
- Customer manager => National Sales Manager

First human task => Second human task
- Sales manager => Commercial Director

I don't know if is correct to handle this with gateways or actor filters.

Thanks.

2 answers

1
0
-1
This one is the BEST answer!

Hi Yuri,

I also think that Actor Filter is a good option for the use case that you describe.

You can find a working implementation example of a process using a custom Actor Filter that behaves like that:

If 'Step1' has been performed by someone having the role 'Customer manager' then 'Step2' is assigned to users having the role 'National Sales Manager'.

If 'Step1' has been performed by someone having the role 'Sales manager' then 'Step2' is assigned to users having the role 'Commercial Director'.

In my example I used only roles, but maybe you have a more elaborate role / group / membership structure, I let you adapt the example to your need.

The example has been implemented using Bonita Community 7.10.3 and the source code (.bos) is available there: GitHub:bonita-forum-answers How to check initiator user role during human tasks

Let me know if this helped you answer your question,

Captain Bonita

1
0
-1

Hi,

You are describing the use case of an Actor Filter. You will have to build a custom one though, as the logic you desire is not supported by the default filters.

https://documentation.bonitasoft.com/bonita/7.10/actor-filtering

https://documentation.bonitasoft.com/bonita/7.10/creating-an-actor-filter

I've spent a little time thinking about how the logic for this filter would work. I think that there is no way to get role information from a User object or from a User Id.

You could easily have some code like this:

Long initiatorId = apiAccessor.getProcessAPI().getProcessInstance(processInstanceId).getStartedBy();
User initator = apiAccessor.getIdentityAPI().getUser(initiatorId);

To get the User that initiated the process instance. I'm struggling to figure out an efficient way to get the User's role without looping through every role in your organization to find which role that specific user has. Perhaps you can figure it out using the Engine API documentation, or someone else can chime in.

https://documentation.bonitasoft.com/javadoc/api/7.10/overview-summary.html

Comments

Submitted by yuri.redaelli_1... on Tue, 03/31/2020 - 09:53

Thanks for your answer but how I can get the current logged user and not only the process initiator?

I'm struggling with the documentation.

Notifications