Find and access the user task to which my boundary event is attached

We have a User Task with a Timer Boundary Event. An ExecutionListener is triggered when the timer is fired. The ExecutionListener contains the code to send reminder to task assignee and owner. Also the content and format of the mail depends on the task id. Inside the ExecutionListener, is there a way to find and access the user task to which my boundary event is attached. I am not able to find anyway whatsoever to find the task object from ExecutionListener.

Same question as o/p. My attempt involved using Execution listener configuration as such:
Event: End
Expression: #{mySpringBean.onTimer(execution.currentFlowElement.attachedToRef)}

That provides the onTimer method with a org.flowable.bpmn.model.UserTask, but I was hoping for something more along the lines of a org.flowable.task.service.impl.persistence.entity.TaskEntity. Specifically, it seems like the UserTask is more like a definition and not an instance.

Flowable folks, how can I/we get the user task instance by way of execution listener expression here?


Valentin Z. was kind enough to share an answer for this. The skinny of it is is that you need to query the TaskService using the process instance id and the task’s (from which the boundary event is associated) definition key. My prior example expression would then look like:

#{mySpringBean.onTimer(execution.processInstanceId, execution.currentFlowElement.attachedToRefId)}

And the Java code:

void onTimer(String processInstanceId, String taskDefinitionKey) {
Task task = taskService.createTaskQuery()


Hope that helps anyone else who may need it!