I want to get username of user who completed a user task in a camunda process.
for example consider a BMPN with only 2 steps , first is a user task and second is a externalTask. for a invocation of this BPMN if a user completes first user task then i should be able get its username in second externalTask.
I did not find any process variable being set in camunda after user task is complete.
The user who completed a user task in Camunda can be stored using a Task Listener. To set this up:
Select the user task where you wish to record the data
In the properties panel go to the 'Listeners' tab and click + in the 'Task Listener' section
Set the 'Event Type' to 'complete'
Set the 'Listener Type' to 'Expression'
Enter the expression:
${task.execution.setVariable('taskCompletedBy', task.assignee)}
When the user task is completed the task listeners expression will be executed. The expression takes the username from task.assignee
, then uses the setVariable()
function on the execution scope task.execution
to store it in a variable. As the variable is stored on the execution scope it's available to the rest of the process. You can then use the variable as with any other variables in later user / service tasks.