# Gateway expression for task variable to trigger a revise scenario?

**URL:** <https://forum.camunda.io/t/gateway-expression-for-task-variable-to-trigger-a-revise-scenario/10858>\
**Category:** Discussion & Questions\
**Created:** [January 29, 2019, 10:02am UTC](https://forum.camunda.io/t/gateway-expression-for-task-variable-to-trigger-a-revise-scenario/10858 "2019-01-29T10:02:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CamundaCommando](https://forum.camunda.io/user_avatar/forum.camunda.io/camundacommando/32/5217_2.png) [@CamundaCommando](https://forum.camunda.io/u/CamundaCommando)\
**Post date:** [January 29, 2019, 10:02am UTC](https://forum.camunda.io/t/gateway-expression-for-task-variable-to-trigger-a-revise-scenario/10858/1 "2019-01-29T10:02:20Z")

</div>

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.

 ![sdad](https://forum.camunda.io/uploads/default/original/2X/9/95b05b610963f76fd79842e12614b8c29307337e.png)

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.

 ![rework%20scenario](https://forum.camunda.io/uploads/default/original/2X/6/60c38612145ae2bfe821be676b0475a1a8e5e1a3.png)

Any ideas how to improve this?

For me, the solution is working.

---

<div class="post-metadata">

**Author:** ![MichiDahm](https://forum.camunda.io/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@MichiDahm](https://forum.camunda.io/u/MichiDahm)\
**Post date:** [January 29, 2019, 12:17pm UTC](https://forum.camunda.io/t/gateway-expression-for-task-variable-to-trigger-a-revise-scenario/10858/2 "2019-01-29T12:17:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [January 30, 2024, 11:33am UTC](https://forum.camunda.io/t/gateway-expression-for-task-variable-to-trigger-a-revise-scenario/10858/3 "2024-01-30T11:33:00Z")

</div>

Closed on January 30, 2024, 11:33am UTC


