8. Task Outcomes (Gateway Decisions)

Rule: If a task leads to an Exclusive Gateway, that task must have an enum type form property to capture the decision.

Why

  • The UI automatically renders enum options as radio buttons (≤4 options) or dropdown (>4 options)
  • No need to parse gateway conditions from BPMN XML
  • The selected option becomes a process variable that the gateway evaluates

Complete Example

<!-- User Task with Decision Enum -->
<userTask id="managerReview" name="Manager Review" flowable:assignee="manager1@workingflow.com">
    <extensionElements>
        <activiti:formProperty id="decision" name="Decision" type="enum" required="true">
            <activiti:value id="approved" name="Approve Request"/>
            <activiti:value id="rejected" name="Reject Request"/>
            <activiti:value id="needinfo" name="Need More Information"/>
        </activiti:formProperty>
    </extensionElements>
</userTask>

<!-- Gateway evaluates the decision variable -->
<exclusiveGateway id="decisionGateway"/>

<sequenceFlow id="flow_approved" sourceRef="decisionGateway" targetRef="approvedTask">
    <conditionExpression xsi:type="tFormalExpression">${decision == 'approved'}</conditionExpression>
</sequenceFlow>

<sequenceFlow id="flow_rejected" sourceRef="decisionGateway" targetRef="rejectedTask">
    <conditionExpression xsi:type="tFormalExpression">${decision == 'rejected'}</conditionExpression>
</sequenceFlow>

<sequenceFlow id="flow_needinfo" sourceRef="decisionGateway" targetRef="requestInfoTask">
    <conditionExpression xsi:type="tFormalExpression">${decision == 'needinfo'}</conditionExpression>
</sequenceFlow>

Supported Gateway Expressions

Flowable evaluates expressions at runtime. You can use calculations and comparisons directly in gateway conditions without needing Script/Service Tasks:

Operation Example Description
Arithmetic ${quantity * price > 1000} Add, subtract, multiply, divide
Comparison ${total > 100}, ${status == 'approved'} Equals, not equals, greater/less than
String Concatenation ${firstName + ' ' + lastName} Combine string values
String Methods ${name.startsWith('A')}, ${email.contains('@')} Call Java String methods
Boolean Logic ${approved && amount < 5000} AND (&&), OR (`
Date Comparison ${endDate.after(startDate)}, ${endDate.before(startDate)} Compare java.util.Date values

Tip: You don't need to store calculated results in a variable first—just put the full expression directly in the <conditionExpression>.