If Node in Pathways
The If node in Pathways is used to create conditional logic within a workflow. This node evaluates a given condition and determines which branch of the workflow to execute based on whether the condition evaluates to true or false.
Configuration Options
- Name
- Assign a name to the node that describes the condition being evaluated (e.g., "Check Data Validity").
- Condition Expression
- Type: Choose the format in which the condition is written:
- Script: Use a scripting language to write complex conditions.
- Handlebars Template: Use Handlebars syntax for conditions based on template-driven logic.
- Expression Field: Define the actual condition to evaluate. This could involve comparisons, checks, or dynamic expressions based on workflow variables.
- Type: Choose the format in which the condition is written:
Purpose and Benefits
- Decision Making: Allows workflows to diverge into multiple paths based on logical conditions.
- Dynamic Execution: Executes only the relevant tasks, improving efficiency and reducing unnecessary computations.
- Customizable Logic: Supports both scripting and template-based logic, catering to different levels of complexity.
Behavior
- True Path: Executes tasks in the branch if the condition evaluates to true.
- False Path: Executes tasks in the branch if the condition evaluates to false.
Usage Scenarios
- Validation Checks:
- Example: Verify if a form submission is complete. If true, proceed to data processing; if false, notify the user of missing fields.
- Data Routing:
- Example: Direct high-priority tasks to a separate processing queue while routing low-priority tasks to a different workflow.
- Conditional Actions:
- Example: Send an email if a threshold is exceeded; otherwise, log the data for later review.
Example Configuration
- Condition Type: Script
- Expression: user.age >= 18
- This checks if a user's age is 18 or above.
- True Path: Execute tasks for adults.
- False Path: Execute tasks for minors.
The If node is a vital component for creating flexible and intelligent workflows in Pathways, enabling dynamic branching based on logical conditions.