Skip to main content

Formula Branching ExecModule

Overview

FormulaBranchingModule version 2.0 evaluates one boolean expression against workflow variables and selects the canonical DEFAULT, CONDITIONAL, or FAILURE graph outcome. It is a deterministic, local control module: it does not call an API, mutate business data, resolve an approval, or dispatch a task itself.

The v2 contract declares the expression context and every output, rejects invalid outcome names, requires a target for a selected conditional branch, clears stale output before each run, and emits content-free failures without copying expressions or variable values.

Use Formula Branching when one expression should control graph flow. For ordered rule sets, multiple destinations, labels, or field-operator forms, use ConditionalBranchModule instead of duplicating those rules in a formula.

Usage

  1. Configure a bounded expression using variable names from the workflow input map.
  2. Choose the onTrue and onFalse graph outcomes.
  3. Set nextTaskId whenever the branch that may be selected is CONDITIONAL.
  4. Pass variables directly in workflow input, or put the exact expression context in the optional variables object.
  5. Route using getBranchOutcome() and, for a conditional edge, branch_taskId.

The engine-compatible output key remains branch_taskId. Version 2 preserves that key for saved workflows while correcting its catalog type from object to string.

Inputs

InputTypeRequiredDefaultDescription
variablesobjectNo{}Explicit expression context with at most 1,000 properties. If omitted, the complete workflow input map is used.

Every variable key must be a non-empty string. When variables is present, sibling workflow input fields are deliberately excluded from the expression context so the evaluated scope is explicit.

Outputs

OutputTypeConditionDescription
statusstringAlwayssuccess after evaluation and routing, otherwise error.
conditionResultbooleanSuccessful evaluationBoolean value returned by the condition evaluator.
branchOutcomestringAlwaysSelected DEFAULT, CONDITIONAL, or FAILURE outcome.
branch_taskIdstringSelected outcome is CONDITIONALConfigured workflow task identifier for the conditional edge.
errorobjectFailureSafe code, generic or field-specific message, and retryable: false.

The error object never contains the expression text, evaluated variable values, or an evaluator exception message.

IntegrationAccount Requirements

No IntegrationAccount is required or read. Formula Branching performs no credential lookup, network request, persistence, or external delivery.

Any downstream module selected by the branch remains responsible for its own authorization, IntegrationAccount, idempotency, rate limits, approvals, and side effects.

Configuration

FieldTypeRequiredDefaultDescription
expressionstringYesNon-empty boolean expression, at most 4,096 characters.
onTrueselectNoCONDITIONALOutcome when the evaluator returns true.
onFalseselectNoDEFAULTOutcome when the evaluator returns false.
nextTaskIdstringConditionalNon-empty, control-character-free task identifier of at most 255 characters. Required when the selected outcome is CONDITIONAL.

The supported outcomes are exactly DEFAULT, CONDITIONAL, and FAILURE, matched case-insensitively. Unknown values fail closed rather than silently becoming DEFAULT.

Operations

Each execution follows the same bounded sequence:

  1. Clear the prior output map and reset the in-memory outcome.
  2. Validate expression text, routing outcomes, and optional task identifier.
  3. Resolve either the explicit variables object or the direct workflow input map.
  4. Require at most 1,000 top-level variables with non-empty string keys.
  5. Evaluate through the repository ConditionService, which prefers OpenXLS when available and otherwise uses the JEXL-compatible evaluator.
  6. Select onTrue or onFalse from the boolean result.
  7. Require nextTaskId if the selected outcome is CONDITIONAL.
  8. Emit the routing receipt and the canonical BranchOutcome.

Identical configuration and variables produce identical routing output.

Errors and Failure Modes

Error codeCauseRetryableRecovery
INVALID_CONFIGURATIONMissing, non-string, oversized, or control-bearing configuration; invalid outcome; malformed variable context; or missing selected conditional target.NoCorrect the named contract field and rerun.
EVALUATION_FAILEDThe condition evaluator throws while parsing or evaluating the expression.No automatic retryValidate syntax and referenced variable names without relying on prior output.

Both failures clear earlier success data, select FAILURE, and omit conditionResult and branch_taskId. The module never routes from a stale prior result.

Some legacy evaluator syntax errors may normalize to a boolean false rather than throw. Validate critical expressions in a non-production workflow and configure the false branch conservatively.

Example

Configuration:

{
"expression": "score >= 80",
"onTrue": "CONDITIONAL",
"onFalse": "DEFAULT",
"nextTaskId": "task-qualified"
}

Workflow input:

{
"variables": {
"score": 91
}
}

Expected result:

{
"status": "success",
"conditionResult": true,
"branchOutcome": "CONDITIONAL",
"branch_taskId": "task-qualified"
}

The result selects the conditional graph edge. It does not execute task-qualified; the workflow engine applies the routing outcome.

Notes

  • Pagination: not applicable; evaluation consumes one bounded context with at most 1,000 top-level variables.
  • Limits: expression length is 4,096 characters and nextTaskId length is 255 characters.
  • Idempotency: natural and deterministic for identical configuration, evaluator version, and variable context.
  • Rate limits: none; no external service is called.
  • API constraints: expressions use the repository ConditionService syntax. OpenXLS availability can affect which evaluator handles a compatible formula.
  • Destructive behavior: none. The module only returns graph-routing state.
  • Secret handling: expressions and variable values are not logged or copied into failure output. Do not place credentials in workflow expression context.
  • Observability: success and failure emit content-free module events; failure logs only the safe error code.
  • Runtime boundary: merged source and published documentation do not update the deployed Workflow Studio metadata until a backend release exposes version 2 through /v1/modules/metadata.