Private variables for CMMN tasks

Is it possible for CMMN tasks (or even tasks in general) to have their own private variables, or are all variables shared across all tasks in an instance.

I’d like to be able to define 2-3 unique values per task to support some UI work, using common key names. The tasks could potentially be active at the same time.

If someone has a documentation link or code example they could share it would be much appreciated.

Failing that, does anybody have a novel suggestion about how else this could be achieved?

Thanks Steve

For anyone else interested in doing this, I’ve achieved what I wanted by adding a “Script” Execution Listener to each task, and in the associated “Inline Script” associated to the “Start” event added script that creates local variables, for example:

execution.setVariableLocal(“taskname”, “task1”);
execution.setVariableLocal(“modulename”, “comms-service”);
execution.setVariableLocal(“formname”, “task1-form”);

An example BPMN process is as follows: Var Test.bpmn (6.5 KB)

If this process is started, it creates two concurrent tasks that each have their own local unique versions of the named variables (i.e. formname, taskname and modulename).

For CMMN, I have added a Script “Task Listener” to each Human Task in the Case and done a similar thing, although you have to use “caseExecution.setVariableLocal()” instead of “execution.setVariableLocal()” although this doesn’t seem to work and throws an exception as follows:

Cannot submit task form 83dab686-feb3-11e8-af85-3cd92b4da7d0: ENGINE-03051 There was an exception while invoking the TaskListener. Message: ‘Unable to evaluate script while executing activity ‘PlanItem_1’ in the case definition with id ‘VarTestCMMN:2:6b490a2e-feb3-11e8-af85-3cd92b4da7d0’:ReferenceError: “caseExecution” is not defined in at line number 1’

Anyone know why this might be?

Doh, as it’s a Task Listener I needed to use the following in the CMMN case (i.e. use “task.setVariableLocal()” rather than “caseExecution.setVariableLocal()”).

task.setVariableLocal(“taskname”, “cmmn-2”);
task.setVariableLocal(“modulename”, “bearer-service”);
task.setVariableLocal(“formname”, “cmnn2-form”);

Full BPMN and CMMN example models are here:

Var Test.bpmn (7.3 KB)
Var Test CMMN.cmmn (2.4 KB)