How to pass additional info/variables to a user task

Hello all. I’m trying to pass some additional info to my user tasks, but I can’t figure out how. My use-case is something like this: I have a user task that can be started by several different ways - through message intermediate catch events, timers, etc. I’ve attached a sample BPMN that demonstrates this. When receiving the events/messages - they usually contain some additional information - in particular “userId” of the user that triggered the message. I can easily pass that information as context variable to my BPMN. I also have an EventListener defined in my code that listens for create/complete/delete task events - so whenever my “Do something” user task gets activated - I can perform some additional work on the backend.

Screenshot 2022-05-19 at 10.30.37

Is there any way to pass the “userId” information to my user task (“Do something”) so that in the EventListener I can retrieve it and do some additional processing (e.g. write some audit log, etc.)? The caveat being that when the user task is started by the first or second event - the userId should be retrieved from that respective event, but when the user task is started from another flow (e.g. - the timer) - then the userId should be null/not set.

Can I pass an input (or extension property) variable to my user task through the flow arrows coming out of the events/timer?

Hi @dimitar-b,

there are several options for this:

  1. Add a service or script task between each event and the user task. This is visible to everybody.
  2. Add an output mapping to the event. This will add an additional variable, but is invisible to the reader of the process model
  3. Add an end listener to the event. This not currently not supported on Camunda 8 and may be a dead end if you plan for this evironment.

Hope this helps, Ingo

1 Like

Thank you, Ingo,
I think the second option should work for my case. I’ll give it a try.