Overview
Some flow types in Etlworks support scripting and can be conditionally executed by stopping the flow early from within the script.
This technique is useful when a flow is executed independently or when conditional execution is needed without using a workflow.
Examples of flows that support this pattern include:
- Send email
- Execute SQL
- Merge data with template
- Call HTTP endpoint
- Execute Script Local or Remote via SSH
The flow script evaluates a condition and stops execution if the condition is not satisfied.
Example Use Case
A workflow loads data into a data warehouse and then sends an email notification.
The email should only be sent when the number of new orders exceeds a configured threshold.
Instead of executing the email flow every time, the script inside the flow checks the condition and stops execution if the threshold is not met.
When to Use This Technique
This method is useful when:
- a flow runs independently and should not always execute
- conditional logic is needed inside a single flow
- the flow is not part of a workflow
If the flow is executed as a step inside a workflow, it is usually better to configure the condition directly at the workflow step level. See:
👉 Conditional execution in workflows
Configure Conditional Flow Execution
To conditionally stop a flow:
- Create the flow.
- Open the Script field for the flow.
- Add logic that evaluates the condition.
Example:
var ret = null;
if (conditon) {
ret = com.toolsverse.etl.core.engine.TaskResult.STOP;
}
value = ret;If the condition evaluates to true, the flow stops without executing the rest of the logic.
Summary
Flows that support scripting can implement conditional execution by evaluating logic in the script and stopping the flow when necessary.
This approach allows simple conditional behavior without creating a workflow or modifying workflow structure.