The If task is a conditional branching operator in Zeroplat’s Event Designer. It evaluates a given query (expression) and based on the result (true
or false
), the workflow continues along the corresponding branch.
This is similar to an if
statement in programming, allowing you to add logic and control flow to your event sequences.
Purpose
- Apply conditional logic in workflows.
- Execute different tasks depending on dynamic data or user input.
- Control when queries, notifications, or actions should run.
- Avoid unnecessary operations if conditions aren’t met.
Anatomy
- Step name
- Label for the task in the flow.
- Default:
if
.
- Query
- The conditional expression to evaluate.
- Must return a boolean value (
true
orfalse
). - Syntax supports bindings (e.g.,
{{ Input1.value == "John" }}
). - Example:
{{ variable1.isAdmin }}
or{{ Input1.value == "jhon" }}
- Branches
- True branch → Executes if the expression evaluates to
true
. - False branch → Executes if the expression evaluates to
false
.
- True branch → Executes if the expression evaluates to
How It Works
- When the If task runs, the expression in Query is evaluated.
- If the result is true, the workflow continues along the true branch.
- If the result is false, the workflow continues along the false branch.
- Both branches can contain one or more tasks (e.g., show notification, run queries, set variables).
Example 1: Input Validation
Condition
{{ Input1.value == "admin" }}
True branch: Show notification → “Welcome, admin!”
False branch: Show notification → “Access denied.”
Example 2: Variable-Based Check
Condition
{{ variable1.balance > 1000 }}
True branch: Execute query → approveLoan
False branch: Show notification → “Insufficient balance.”
Example 3: Combined Expression
Condition
{{ (Table1.selectedRow.status == "Active") && (variable1.isAdmin) }}
True branch: Show page → Edit form
False branch: Show notification → “You are not allowed to edit inactive records.”
Best Practices
- Keep expressions simple → For complex logic, use a Transformer or JS Query, then return a boolean for the If task.
- Name your steps clearly → e.g.,
ifUserIsAdmin
instead of justif
. - Use variables → Store reusable conditions in variables to simplify expressions.
- Combine with notifications → Great for showing validation errors or guiding users when conditions aren’t met.
FAQ
Q: Can I use multiple conditions?
- Yes, using logical operators:
&&
(AND),||
(OR),!
(NOT).
Q: What if the expression doesn’t return true/false?
- Non-boolean values may lead to unexpected behavior. Always ensure the result is strictly boolean.
Q: Can If tasks be nested?
- Yes. A true/false branch can contain another If task for more complex decision trees.
👉 In summary: The If (Switch) task is the key to adding conditional logic in Zeroplat workflows. It enables dynamic, data-driven branching so that applications can react intelligently to user input and system state.