cancel
Showing results for 
Search instead for 
Did you mean: 

Can I obtain assignee Id from listener?

felipe1
Champ in-the-making
Champ in-the-making
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
         
      }
   }
}
5 REPLIES 5

trademak
Star Contributor
Star Contributor
Hmm looks like a bug. Could you create a JIRA issue?

Best regards,

felipe1
Champ in-the-making
Champ in-the-making
I would love to, but apparently I do not have a JIRA account on http://jira.codehaus.org/browse/ACT. Can you help me with that?

trademak
Star Contributor
Star Contributor
Just signup here:

http://xircles.codehaus.org/signup

Best regards,

felipe1
Champ in-the-making
Champ in-the-making
Thanks Tijs, issue created: http://jira.codehaus.org/browse/ACT-1831

mandas
Champ in-the-making
Champ in-the-making
You can try observe for @CreateTask and @AssignTask, get the variable scope from the event and cast it to DelegateTask. (>=5.14)

Dimitris

edit: Added more info