Input parameters of task (e.g. user task) are displayed as local variables (inside the cockpit), but not supplied via a REST API call like “…/api/engine/engine/default/task/taskId/localVariables”. Is this a bug?
Hi @setu
The variables you see in cockpit are process instance variables (have a look at the scope column).
Try to select any task listed on the User Tasks tab then select the Variables tab to see the local task variables
/task/{id}/variables
Retrieves all variables visible from the task. A variable is visible from the task if it is a local task variable or declared in a parent scope of the task
https://docs.camunda.org/manual/7.5/reference/rest/task/variables/get-task-variables/
/task/{id}/localVariables
Retrieves all variables of a given task.
https://docs.camunda.org/manual/7.5/reference/rest/task/local-variables/get-local-task-variables/
Expanding on Hassan’s answer, having an input parameter on a BPMN user task does not make the variable a task-local variable, but an execution-local variable on the execution of that BPMN task. See https://docs.camunda.org/manual/7.5/user-guide/process-engine/variables/#variable-scopes-and-variable-visibility for an example.
Hi Thorben,
thanks for your answer.
Inside cockpit input parameters are displayed as local variables. For example, i create a task named “mytask” and a input parameter named “myvar”. Inside the cockpit “myvar” is displayed with scope “mytask”. Therefore, I conclude “myvar” is a local varibale to task “mytask”. A second reason for my assumption: As soon as a task is finished, an input parameter no longer exists.
Also, there is no information in “https://docs.camunda.org/manual/7.5/user-guide/process-engine/variables/#variable-scopes-and-variable-visibility” if input parameter are local or not
In my opinion is that it makes sense defining input parameter as local !
Hi @setu,
When you have a userTask
element in BPMN XML with input parameters, the process engine is going to generate during process execution two variable scopes that live only for the time of the task being active: One execution e and one task t (task as in the objects TaskService
manages). In the scope hierarchy, e is a child of the execution that encountered the user task, and the t is a child of e. Input parameters then become local variables on e. They are therefore not local on t, but can be accessed from t via the non-local methods. Local variables on t are not accessible from e.
While this may not be desired for your use case, I think it makes sense. You can have input parameters with any kind of BPMN task, i.e. those that do not manifest themselves in a task instance. Thus, making input parameters become local variables on the task would be inconsistent.
I agree that the documentation is not specific about this behavior.
Cheers,
Thorben
I am using java camunda api not the REST approac. I have a task which can be created when ever a forward task is been called, means several users will be getting the task assigned to them based on who calls it. and I am setting a variable via runtimeService message firing. But am not able to access the variable data for each assigness task instead it shows the last created task variable [issue can be the scope or ?]