Gateway expression for task variable to trigger a revise scenario?

I am trying to model a scenario where 3/4 concurrent user tasks can reject or approve a process and the gateway at the end will then switch accordingly.

The problem though is that the global scope of the variable means it can become mutated by another user task e.g.

  • User 1 - true
  • User 2 - false
  • User 3 - false

The gateway expression ${rework == “true”} will not be triggered and the default flow will be used.

The only way I could get it working was to make this very ugly BPMN diagram with gateways after each user task.

Any ideas how to improve this?

For me, the solution is working.

Hi @CamundaCommando,

you can try the following:

In the tasks where you set the boolean “rework” add an ExecutionListener with the EventType “end” and use a Script (e.g. JavaScript) to create the logic:

var value = execution.getVariable(“rework”);

var theValueYouWantToSet = …

if(value == false && theValueYouWantToSet == true){
value = true;
}

execution.setVariable(“rework”, value);

If you do it like this you don’t always just overwrite the variable, and you can check and specify when exactly you want to update the value. So if the value was “true” once it will not be reset to “false”.

Hope that helps.

Regards
Michael