Camunda Extensions

Conditional Sequence Flow

A sequence flow can have a condition defined on it. When a BPMN 2.0 activity is left, the default behavior is to evaluate the conditions on the outgoing sequence flows. When a condition evaluates to ‘true’, that outgoing sequence flow is selected. When multiple sequence flows are selected that way, multiple executions will be generated and the process is continued in a parallel way. Note: This is different for gateways. Gateways will handle sequence flows with conditions in specific ways, depending on the gateway type.

A conditional sequence flow is represented in XML as a regular sequence flow, containing a conditionExpression sub-element. Note that at the moment only tFormalExpressions are supported. Omitting the xsi:type=“” definition will simply default to this type of expression.

Currently, conditionalExpressions can be used with UEL and scripts. The expression or script usedshould resolve to a boolean value, otherwise an exception is thrown while evaluating the condition.

  1. <![CDATA[${order.price > 100 && order.price < 250}]]>
  2. </conditionExpression>

This example invokes a method that resolves to a boolean value.

In this example a simple groovy script is used to evaluate a process variable status.

  1. <![CDATA[status == 'complete']]>

Similar to a script task, an external script resource can also be specified (see the documentationon script source for more information).

Extensions for conditionExpression

Attributes
Extension Elements
——-
Constraints
——-

Default Sequence Flow

A default sequence flow for a certain activity is defined by the default attribute on that activity. The following example shows an exclusive gateway with a default sequence flow. Only when x is neither 1 nor 2 it will be selected as outgoing sequence flow for the gateway.

Note the ‘slash’ marker at the beginning of the default sequence flow. The corresponding XML snippet shows how flow4 is configured as a default sequence flow.

  1. <exclusiveGateway id="exclusiveGw" name="Exclusive Gateway" default="flow4" />
  2. <sequenceFlow id="flow2" sourceRef="exclusiveGw" targetRef="theTask1" name="${x==1}">
  3. <conditionExpression xsi:type="tFormalExpression">${x == 1}</conditionExpression>
  4. <sequenceFlow id="flow3" sourceRef="exclusiveGw" targetRef="theTask2" name="${x==2}">
  5. <conditionExpression xsi:type="tFormalExpression">${x == 2}</conditionExpression>
  6. </sequenceFlow>
  7. <sequenceFlow id="flow4" sourceRef="exclusiveGw" targetRef="theTask3" name="else">