activiti Process Variables与TaskLocal Variables区别

    最初接触activiti的时候,对taskService中的setVariableLocal和runtimeService中的setVariable有些不理解,最终在官方论坛中找到了相关的解释:task中设置的只对当前的task有效,runtimeService中的是对整个流程有效。如下:

http://forums.activiti.org/content/process-instance-variable-and-task-local-variable

Task variables are only available within the task itself. Once the task is complete, they are gone (although present in history if configured to historyLevel FULL).

Setting process variables from API:

runtimeService.setVariable(processInstance.getId(), "varName", "value");

Setting task variables from API:

taskService.setVariableLocal(task.getId(), "varName", "value");