AnsweredAssumed Answered

Task Scoped variables

Question asked by bkwf2 on Mar 14, 2012
Latest reply on May 29, 2014 by martin.grofcik

I have some questions regarding task scoped variables.

I have a process with 4 tasks like below:

      [Task 1] —> [Task 2] —> [Task 3] —> [Task 4]

When user completes Task 1 certain business data is generated and I want to set this data in "Task" scope so that when control passes to the task 2 I can access the data.

In order to complete the task 1 I call the below code:

TaskService taskService = getTaskService();
taskService.complete("task_1_Id", variables);
But the variables are set in the "PROCESS" scope since when I check table "ACT_RU_VARIABLE" table I see the "TASK_ID_" column as NULL. This is correct since the task ends with call to "complete". And yes when I reach Task 2, I can access these variables using "taskService.getVariables(taskId)", but this method will access the variables in "PROCESS" scope also.

I tried using the below code to store the variables at a "local" scope:

TaskService taskService = getTaskService();
taskService.setVariableLocal(taskId, varName, value);

But this also did not help.

To cut to the chase I am trying to limit some variables to "TASK" scope which would not be visible at the "PROCESS" level. Is this possible..?
Or are all variables always stored in "Process scope"..?
Or am I not understanding the scopes correctly..? I have read the Activiti docs from top to bottom, but could not find a clear explanation of "scopes". I know one thing that there is a local scope and variables are first searched at local scope and then in the parent scope. :roll:

thnx for any advice.