In a process, I have defined a Task Listener to send a mail including the URL to the tasklist. This seemed to work fine, but today, the query to get the Task stopped working properly. I was using list() and .get(0) before which selected wrong names, probably I was just lucky that it worked in the past. However, I must be missing something obvious here. delegateTask.getId() returns the proper task ID, so why is my query to the TaskService failing and returning null instead of the task?
I could swear that there wasn’t a getName() function on it the last time I tried. Probably my Eclipse either bugged or I just failed.
So the reason why I don’t get it via the DB query is that the task isn’t persisted to the database when the create task listener is called? Would make sense, since it isn’t called afterCreated.
Replacing it with a decent delegateTask.getName(); obviously did it.
@Ingo_Richtsmeier, when we configure TaskListener in the eventType=“create” , during execution the task listener code will be get executed before/after task creation?
I hope it would be after creation of the task entity, if yes, before/after persistence of task entity?
The task event cycle is reworked and clarified in the upcoming Camunda Release 7.12. The latest docs says:
The create event fires when the task has been created and all task properties are set. No other task-related event will be fired before the create event. The event allows us to inspect all properties of the task when we receive it in the create listener.