AnsweredAssumed Answered

TASK_CREATED event fired after its userTask execution

Question asked by cnirparis on Feb 3, 2016
Latest reply on Feb 5, 2016 by jbarrez

I've defined in my
a listener class which implements
. This class tests the event type TASK_CREATED for doing some work before the task. But I have two problems :

1) I have to check the task name which has fired the event. I use this code :

Task t =  ts.createTaskQuery().processInstanceId(event.getProcessInstanceId()).orderByExecutionId().desc().singleResult();
if (t != null)
taskId = t.getId();
taskName = t.getName();

but sometimes, specially with the first task of the process, I get 'null' values, so I cannot know which task fired the event.

2) the event TASK_CREATED is fired AFTER the same name task is executed , as it appears in the logging.
How can I ensure that the event is fired before the task begins to work ?

Thank you.