Can I get information from a linked userTask, and use it in a serviceTask

Consider a setup for a user-task with an reminder-email (part of the BPMN below):

  • A user task for some action to be done by a human;
  • A non-interrupting boundary timer event to act after 24 hours;
  • A service task to send a reminder email.

The initial flowable:assignee in the example is “Jack”, so he will get the task on his to-do list. Now Jack decides to re-assign the task to another user, say “Mary”. This all works fine until the timeout happens and the service-task needs to send the reminder email.

How can this service-task know the actual assignee (“Mary” in the example)?

<userTask id="assess" name="Do an assessment" flowable:assignee="Jack" > <incoming>f0</incoming> <outgoing>f1</outgoing> </userTask> <sequenceFlow id="f1" sourceRef="assess" targetRef="end" /> <boundaryEvent id="reminderEmailEvent" cancelActivity="false" attachedToRef="assess"> <outgoing>f2</outgoing> <timerEventDefinition id="TimerEventDefinition_0zmoq74"> <timeDuration>PT24H</timeDuration> </timerEventDefinition> </boundaryEvent> <sequenceFlow id="f2" sourceRef="reminderEmailEvent" targetRef="reminderEmail" /> <serviceTask id="reminderEmail" name="Send reminder email" flowable:expression="#{mailService.sendReminderMail()}"> <incoming>f2</incoming> <outgoing>f3</outgoing> </serviceTask>

You can use the TaskService to query for information about tasks. In this case, you’ll need to get the process instance ID somehow. If you used a DelegateExpression instead of an expression and implemented a JavaDelegate, you’d have some execution information from the DelegateExecution that gets passed in.