How to control the flow when candidate group is used for human tasks?

Good morning everyone.

I need this workflow where some of the human tasks are defined to use candidate group for the assignment.

The problem is that I need to be able to control the flow, like, for some taks, I need a number of approvals to have the flow advancing to the next tasks, and for others, I have some different logic to do the same.

Is it possible to define some logic in the task or execution listener to do this?
Some examples:
check if I have 2 approvals, then advance, if not, wait for more users to finish the task;
if I have 2 denials, go ahead and advance in the flow.

I was using the Completion Condition with the Collection element to do the logic, but that is causing problems, as the assigment has to be dynamic, as new users can become members of the groups I used in the collection variable.

So, my doubt would be simply, how to decide and force the remaining tasks to be removed and let the flow advance.

Thank you in advance.

There’s a few ways to do this. Using a completion condition is indeed one way. If the logic becomes too complex, you can always use a custom expression and call a bean to move the logic there.

Another option to do what you describe is throw an intermediate signal event after each task completion that, preceded by a gateway + a service task or hidden listener that calculates whether to throw the signal. This signal can be caught on the boundary of a subprocess that is configured to interrupt everything inside.

Nice, I will read about and try the options.

But talking about the completion condition, isn’t it supposed to be used only with multiInstanceLoopCharacteristics?
Checking the bpmn file, I saw this:

<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="comiteCreditoPaMembers" flowable:elementVariable="assignee">
    <completionCondition>${nrOfCompletedInstances &gt; 0}</completionCondition>

Is it supposed to work also with the candidate group?

Thank you for your time.