I have a workflow with parallel user tasks assigned to different users.For each of these parallel tasks, I need to send reminders to the assignee. Because only the user that has not completed the task has to receive the reminder, I used a "multiple instance subprocess" to spawn the parallel tasks.Each task has a timer boundary that starts every N minutes a task service that is supposed to send the email reminder.Everything works but I would like to do a small change and for this I need to know to which user task the task service is "attached".The only solution I found is to add a listener in the user task that sets the following variable when the task is created:
execution.setVariable("bpm_currentExecutionId", execution.getId());
In the handler for the service task, I can read this variable and use the ServiceTask to get the task:
String userTaskExecutionId = execution.getVariable("bpm_currentExecutionId");
TaskEntity userTask =
execution.getEngineServices().getTaskService().createTaskQuery().executionId(userTaskExecutionId ).singleResult();
Is there a better way ?