Component: Bonita | Version: N/A
**Related article: Dispatch tasks to users: how to do it with Bonita **
Question
We are trying to link a user to his manager, with specific custom information.
In order to do this, we have created two custom information (agent and director) and set the user’s ‘director’ custom information the name of its director.
We want the director and the default bonita manager to be different.
The purpose of this operation is then to be able to set up an actor filter on a task: only the director of the agent having initiated the process must have access to this task.
For example, for the user walter.bates (agent), we specify april.sanchez in the custom information “director” (walter.bates’s bonita manager is helen.kelly).
So, if walter.bates initiates the process, we want the next task to return to april.sanchez only.
We have therefore created a “unique user” actor filter, where we want to return via a script the identifier of the director associated with the initiator.
How to return the value of the director custom information for the user?
Answer
You need to implement the actor filter to retrieve the Custom information set in the organization as follow, this is a simple example :
import org.bonitasoft.engine.identity.CustomUserInfo;
import org.bonitasoft.engine.identity.User;
import java.util.logging.Logger;
Logger logger = Logger.getLogger("org.bonitasoft");
User Initiator = BonitaUsers.getProcessInstanceInitiator(apiAccessor,processInstanceId);
logger.severe("# initiatorId: " + Initiator.getId() + " first name: " + Initiator.getFirstName()+ "#");
List<CustomUserInfo> listCustoInformation = apiAccessor.getIdentityAPI().getCustomUserInfo(Initiator.getId(),0,100);
for (CustomUserInfo customUserInfo : listCustoInformation) {
if (customUserInfo.getDefinition().getName().equalsIgnoreCase("director")) {
logger.severe("# directorName: " + customUserInfo.getValue() + " #");
return customUserInfo.getValue();
}
}
return -1;