AnsweredAssumed Answered

Why does it risk to update a variable during a process ?

Question asked by fabrice1 on Jun 2, 2014
Latest reply on Jun 3, 2014 by martin.grofcik

I'm looking to update a variable and I found this topic

Mr Barrey told this
"Why would you want that? [update a process variable] It would screw the transaction going on at that time"

Why do we do to avoid that ? Is there a workaround ?

In my case I have a subprocess because several people have to accomplish a task .
I created a List of string to include people Id and to inject in a process

Actually, when process is started and  before subprocess, I have to check if any other people have to accomplish a task in subprocess or not (because between the beginning of the whole process and the subproccess call , it exist a while of 14 days.)

So before starting process I do this

List<String> people=  new ArrayList<String>();
      String person1= "id1";
      String person2= "id2";
      String person3= "id3";


Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("peopleForSubprocess", people);

BUT when process is started , if a person is detected to accomplish the subprocess, we have to update the variable :
List<String> people = (List<String>) runtimeService.getVariable(processId, "peopleForSubprocess");

String sup4 = "id4";
people .add(sup4 );

runtimeService.setVariable(task.getExecutionId(), "peopleForSubprocess", people );

Can we do that ?
Or is it better to create a new variable ? (but it seems impossible because , a subprocess can get only one collection)

Thanks in advance