Skip to main content

Control

The Control section of the node panel shapes the path the flow takes. Use it to branch on a condition, dispatch on a pattern, repeat steps, iterate over a collection, or return a value to the caller. Every form in this section accepts Ballerina expressions; author them with assistance from the Expression editor.

If

Branches the flow on a Boolean condition and runs the matching block. Add Else If blocks for additional conditions and an Else block for a fallback path when none of the conditions match.

If button in the Control section

FieldDescription
ConditionBoolean condition.

The form provides Add Else IF Block and Add Else Block to extend the branch.

If form with Condition field and Add Else IF Block and Add Else Block actions

Match

Matches a value against one or more patterns and runs the steps under the first matching pattern. Use Match instead of a chain of If/Else If blocks when dispatching on a finite set of values or shapes.

Match button in the Control section

FieldDescription
TargetMatch target expression.
Pattern 1Binding pattern that the target is matched against.

The form provides Add Case Block to add more patterns and Add Default Case Block for a fallback that runs when no pattern matches.

Match form with Target and Pattern fields

While

Loops over a block of code as long as a Boolean condition holds. The condition is evaluated before each iteration; the loop ends when it becomes false.

While button in the Control section

FieldDescription
ConditionBoolean condition.

While form with Condition field

Foreach

Iterates over a block of code for each item in a collection. Use it for arrays, query results, ranges, and any other iterable value.

Foreach button in the Control section

FieldDescription
CollectionCollection to iterate.
Variable NameName of the loop variable bound to each element.
Variable TypeType of the loop variable. Define new types inline with the Type editor.

Foreach form with Collection, Variable Name, and Variable Type fields

Return

Ends the current function or service flow and produces a value to the caller. The operation has no required parameters; the optional Expression field configures the value to return.

Return button in the Control section

FieldDescription
ExpressionReturn value. Leave it empty for () returns.

Return form with Expression field

What's next

  • Statement — Variables, function calls, and data mapping.
  • Error handling — Catch errors and raise failures inside branches.
  • Concurrency — Fork, wait, and lock for parallel work.
  • Expression editor — Author Ballerina expressions with autocomplete and validation.