Retrieve user who created a task

When triggering an external task, we would need the task processor to have access which user was acting (if any) on the process that triggered that task.

For example, we have a user task whose next task is an external task. The task processor will call a webservice and forwards some data, like the current user if available and so on. Is this achievable?

Hi Edmondo Porcu,
I think you could store the authenticated user of the user task as a process variable

Then you could fetch the variable as follow


Variables that are required to perform a task can be fetched along with the task. For example, assume that the AddressValidation task requires an address variable. Fetching tasks with this variable could look like:

List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(10, "externalWorkerId")
  .topic("AddressValidation", 60L * 1000L).variables("address")

for (LockedExternalTask task : tasks) {
  String topic = task.getTopic();
  String address = (String) task.getVariables().get("address");

  // work on task for that topic

The resulting tasks then contain the current values of the requested variable. Note that the variable values are the values that are visible in the scope hierarchy from the external task’s execution. See the chapter on Variable Scopes and Variable Visibility for details.