Get specific UserTask after boundery event

I defined a “non-interupting” boundery timer-event on a UserTask. And I would like to send a reminder notification with a generic service (JavaDelegate) and send information based on the context. For example:

In the JavaDelegate i get a “DelegateExecution” context object but I would like to know from what user task it is originated.

When I query the user tasks by processInstanceId I obviously get two user tasks but I can’t figure out how to get the task from wish the boundary event is originated. And help/hint would be appreciated?

1 Like

Hey @Ron_Alders,

Each service task should have unique activity ID. From the DelegateExecution you could just call getCurrentActivityId() and depending on the ID you could find out from which task the boundary was triggered.

Another solution would be that you implement to different JavaDelegate classes, one for each service task. But that might be a bit overhead/redundant depending on what you want to do.

Best,
Johannes

1 Like

Hi @JoHeinem,

It could be done like that, but I don’t like creating branches depending on the servicename in my generic service (that would make ik very specfic).
And this this still does not allow me to get access to the taskId to send a specific reminder that points to this task. I thougth i could do something like this.

taskService.createTaskQuery().executionId(execution.getParentId()).list()

But the execution.getParentId() returns the executionId of ProcessInstance (execution before parallell gateway). Is this a bug are is this expected behaviour ?

Regards,
Ron Alders

Hi @Ron_Alders,

Yes, this is expected behavior. Would you could do is to place an execution listener in the boundary event and then pass a variable with the task id. However, when the user task is executed multiple times within the process instance, then you again have a problem, because there are several activity executions of the same task.

Otherwise, it might not possible to achieve your desired generic service in Camunda.

Best,
Johannes

What unique name should the variable be given since it is possible to process multiple taks with the same id when you work with parallel subprocesses. For example like this:

Then you can have multiple tasks with id task1 active within the same process. Then how can I get the task id from wich the boundery event is orginated. Even with custom JavaDelagates this is hard to accomplish. And could anyone explane too me what suppose to be returned from:

execution.getParentId() 

According to javaDoc the following:

/**

  • Gets the id of the parent of this execution. If null, the execution
  • represents a process-instance.
    */

And I get the execution id of the process-instance. But when you inspect the underlaying execution hierarchie it all seems to be correct until a boundery event spawns a execution. Then the chain seems to be broken.

Regards,
Ron

1 Like

Hi @Ron_Alders,

Did you manage to solve your issues and implement the desired functionality?
I’m also trying to implement something similar.

Thanks,
Kostas