One sequence flow should be always executed and other sequence flow should be only executed if certain condition is met

test bpmn.bpmn (7.3 KB)
One sequence flow should be always executed and other sequence flow should be only executed if certain condition is met. In attached bpmn on “Start Event” there is a script “execution.setVariable(‘executeAlways’, true);” and due to that script “Sequence Flow ONE” which has condition expression “${executeAlways == true}” is executed. If variable “someValue” is set to true “Sequence Flow TWO” is executed and if variable “someValue” is set to false “Sequence Flow TWO” in not execute due to the condition expression “${someValue == true}” in “Sequence Flow TWO”.

Is there some other way to achieve this (for example by not using script which hardcodes executeAlways to true and/or using some other gateway or combination of gateways or any other way in general) ?

Hello my friend!

You can, for example, take some process variable that you know will always exist at that stage and use the hasVariable() method to validate the path that should always be executed.

For example, let’s say that as soon as your Camunda is started, a process variable called “myBusinessKey” is created, you can use the expression ${execution.hasVariable("myBusinessKey")}, because this way, you always will have the variable myBusinessKey.

The other way you can model without using Inclusive Gateway might be like this:

I hope this helps!

William Robert Alves

1 Like

Hi @dusan.djosic,

another option to execute a sequence flow “always” is to use the expression ${true}. It’s always true.

Hope this helps, Ingo

2 Likes

Hello @WilliamR.Alves, thank you for your answer!

Approach with checking for process variable which always exists when process instance is started (or anywhere before check) works as expected :slight_smile: Thank you! :slight_smile:

The other way with parallel gateway is interesting approach but don’t seems something which will work for case of my bpmn since the sequence flow which should be executed conditionally should have its own end event, and that end event is different from end event which is on sequence flow which should be always executed. First approach with checking existance of variable seems good enough for now, the question for other approach was more out of curiosity. :slight_smile:

Thank you for help,
Dusan

Hi @Ingo_Richtsmeier,

it works like a charm :slight_smile:

Thank you for help,
Dusan

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.