How to save the output of an actor filter into a variable?



I have a process with a lane on which I have an actor Validator

I have configured an actor filter on this lane.

I need to know who are the users that are associated to the lane because I need to send a notification to them.

In my process I need to send the notification in a service task and then after a while I have a human task.


Submitted by Dibyajit.Roy on Tue, 12/01/2020 - 16:55

I use something like this.

import org.bonitasoft.engine.identity.ContactData;
import org.bonitasoft.engine.identity.Group;
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserCriterion;

import com.bonitasoft.engine.api.IdentityAPI;
import com.bonitasoft.engine.api.ProcessAPI;

IdentityAPI identityapi = apiAccessor.getIdentityAPI();
Group group = identityapi.getGroupByPath("/acme/hr");

List users = identityapi.getUsersInGroup(group.getId(),0,100, UserCriterion.FIRST_NAME_ASC);
String emailList = "";
for(int i=0;i User user = (User)users.get(i);
ContactData contactData = identityapi.getUserContactData(user.getId(),false);
emailList += contactData.getEmail();
emailList += contactData.getEmail()+"," ;


return emailList;

Submitted by enrico.curiotto on Tue, 12/01/2020 - 16:57

Thank you, but I need the users of an actor filter output, not the users of a static group.

1 answer

This one is the BEST answer!

Hi, you can execute the actor filter on a service task prior to the lane tasks but it means that:

  • The actor filter do not depend on execution context
  • The actor filter input is the same between all tasks
  • The actor filter implementation will be coupled with the definition

Then you can use a groovy connector on a service task like this:

import org.bonitasoft.actorfilter.identity.UserManagerActorFilter
import org.bonitasoft.engine.connector.EngineExecutionContext

// Instantiate the actor filter
def filter = new UserManagerActorFilter()
// Configure the execution context
def context = new EngineExecutionContext()
context.activityInstanceId = activityInstanceId
context.processDefinitionId = processDefinitionId
context.processInstanceId = processInstanceId
context.rootProcessInstanceId = rootProcessInstanceId
def processInitiatorId = apiAccessor.processAPI.getProcessInstance(processInstanceId).getStartedBy()
// WARNING: Input parameter must match the one used later in the process

// Execute it

Obviously you should replace the UserManagerActorFilter with the implementation you want to use anf the Employee actor name with your Lane actor.



Submitted by tuan-anh.le on Wed, 12/02/2020 - 17:56

Hello Romain, i'm working with enrico.curiotto. I have tested your solution and it worked. Thank you for your help !!!