cancel
Showing results for 
Search instead for 
Did you mean: 

Send reminders to task assignee

marco_altieri_7
Confirmed Champ
Confirmed Champ
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 ?
3 REPLIES 3

marco_altieri_7
Confirmed Champ
Confirmed Champ
In the example above there are a couple of missing cast:

<code>
String userTaskExecutionId = (String) execution.getVariable("bpm_currentExecutionId");
TaskEntity userTask =
    (TaskEntity) execution.getEngineServices().getTaskService().createTaskQuery().executionId(userTaskExecutionId ).singleResult();
</code>

p4w3l
Champ in-the-making
Champ in-the-making
Wouldn't it be more strightforward to set variable with the particular user name instead of execution id ?

marco_altieri_7
Confirmed Champ
Confirmed Champ
I need the task and not only the assignee because I want to be able to use the workflow notifications that are available OOTB in Alfresco: they need as input the user task. In general, because the solution that I am writing should be reusable for different use cases, I thought it could be better to easily get the whole task.

By the way, the solution that I suggested does not work because the execution.setVariable() set the variable at the process level.