AnsweredAssumed Answered

Sending an email after user task is created

Question asked by jim1 on May 20, 2015
Latest reply on Dec 11, 2018 by krolikzaia
We have a scenario where when a user task is created, a TaskListener is fired (on create) which will create a temporary login for a user and then email them the login details along with the task ID.
We'd like to use a Mail Task to handle the email sending as the content can then be customised in the BPM, so we came up with the following pattern in the BPM:

Start —> Parallel Gateway —> User Task
                 |—-> Message Intermediate Catch Event —> Mail Task

The idea is that once the task listener has finished it's work, it will send the message that the catch event is listening for and the email will be sent.

However, when we query for the execution for the message catch event, no results are returned:

List<Execution> executions = runtimeService.createExecutionQuery()

      if (executions != null && !executions.isEmpty()) {
         for (Execution e : executions) {
            runtimeService.messageEventReceived("LOGIN_CREATED", e.getId());

I'm assuming that activiti is processing the branch from the parallel gateway to the user task first, so at this point the message catch event has not been created. Is there any way around this?

I've created a small unit tests which demonstrates the scenario: