Skip to main content

Branching Tasks

A default task has one endState. By adding the option "isBranchingTask" this behavior is overridden to make it possible to add as many as needed.

Option
isBranchingTask TaskElement

Changes the return type of the task to the State enum. The returned state will define the next state of the instance.

<options>
<isBranchingTask/>
</options>

The success state should be returned as a branchSuccess TaskResult:

return TaskResult.branchSuccess(InvoiceState.NOT_PAID);

You will need to define the States as DataStates before being able to use them.

Using Task Outcomes

note

Using workflows in combination with TaskOutcomes requires the use of the workflow metamodel. Otherwise, the workflow component will not recognise the return type of the task correctly.

Instead of a branching task returning the end-state, the same can be achieved using task outcomes in combination with a workflow model.

<workflow name="InvoiceFlow">
...
<transition name="AssessInvoice">
<beginState component="invoicing" workflow="InvoiceFlow" name="Created"/>
<endStates>
<endState>
<state component="invoicing" workflow="InvoiceFlow" name="Payment Received"/>
<taskOutcome component="invoicing" taskElement="InvoiceAssessment" name="Paid"/>
</endState>
<endState>
<state component="invoicing" workflow="InvoiceFlow" name="Payment Pending"/>
<taskOutcome component="invoicing" taskElement="InvoiceAssessment" name="Not Paid"/>
</endState>
</endStates>
</transition>
</workflow>

The implementation can now use the TaskOutcome return type to provide the result.

return TaskResult.success(InvoiceAssessmentOutcome.NOT_PAID);