How to get User task's cancellation/ending reason from the History service

Actually, what I’m trying to understand is whether the User Task was deleted because of timeout or because the Process was deleted. In this case, I think it is not enough to look at the Process state information only. It will not always give the right result. Let’s look at the following BPMN:

“user task 1” was deleted by the Engine as it was indeed timeout. While the Process was waiting in “user task 2”, I manually deleted Process. So, if I look at the Process state, it’s EXTERNALLY_TERMINATED, but no, “user task 1” was actually deleted because it was timeout, not because I manually deleted the Process.

I really need to capture the status of User Task while it is timeout. As far as I can see, there is no STATE information for Task as in Process.

What can i do for this requirement, then?

  1. Can we make to run EVENTNAME_TIMEOUT in TaskListener? For some reason, this event is not triggered when any User Task timeouts.

Related post I found in the forum: How to add task listener with parseUserTask for user task timeouts

  1. While the User Task is timeout, I can create a local variable related to this situation and then just look at this local variable? (Assuming the deletion of a User Task because of the timeout and the Timer boundary event execution are in the same transaction.)

Maybe related other forum posts:
Get User Task of Timer Boundary Event - #4 by thorben
Examples of 7.12 webinar - #2 by thorben
Get origin of a Boundary Event - #3 by joseluisluri
Lookup Timer Due date for a Boundary event from Task Create Listener - #2 by Philipp_Ossler

  1. Your other elegant solution!

I just have to use Parse Listeners to catch when User Task is timeout. For the user side (designing the Process in Camunda Modeler), if you are using a Timer boundary event connected to any User Task, then you have to add the following bla bla bla should not be the solution.

Thanks.