AnsweredAssumed Answered

Can I obtain assignee Id from listener?

Question asked by felipe1 on Oct 30, 2013
Latest reply on Dec 5, 2014 by mandas
I need to obtain the assignee id whenever a new user task is created. So I've tried to use the "@Observes BusinessProcessEvent" approach, as described in the user guide (http://www.activiti.org/userguide/#N16666).

I can get a reference to a BusinessProcessEvent object, which gives me the processInstanceId and activityId. I have tried to use those to create queries with runtimeService, taskService and historyService, but that did not work. I believe that, in that point the task was not completely created or persisted in the database.

I have also tried to use an injected BusinessProcess. This class has a getTask() method, but that returns always null.


public class TaskObserverActiviti {
   @Inject
   private BusinessProcess businessProcess;

   public void onProcessEvent(@Observes BusinessProcessEvent businessProcessEvent) {      
      if (businessProcessEvent.getType() == BusinessProcessEventType.START_ACTIVITY) {
         Task task = businessProcess.getTask();

                         // task is always NULL
         
      }
   }
}

Outcomes