cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current tasks in ActivitiEventListener (TASK_CREATED event)

marian88
Champ in-the-making
Champ in-the-making
Hi,

I'd like to get task name when a TASK_CREATED event occured.

I have a class that implements ActivitiEventListener and I am trying to get the task name on the event TASK_CREATED.

I do this and currentTasks is null : 

case TASK_CREATED:
            System.out.println("task created");
            List<Task> currentTasks = event.getEngineServices().getTaskService().createTaskQuery().processInstanceId(event.getProcessInstanceId()).list();
            for (Task task : currentTasks) {
            System.out.println("task name: "+task.getName());
         }
            break;


The event contains a TaskEntity instance that doesn't have all fields filled in.

Thank you!

1 REPLY 1

marian88
Champ in-the-making
Champ in-the-making
Aaa sorry, my bad. That task didn't had a name. Stupid!
And I got the  TaskEntity:
<code>
   ActivitiEntityEvent  entityEvent = (ActivitiEntityEvent)event;
    TaskEntity taskEntity = (TaskEntity) entityEvent.getEntity();
</code>