Skip to main content

Condition

The Condition task is a critical component in OSPROV's workflow builder that enables dynamic workflow routing based on data-driven decisions. It allows you to create branching paths in your workflows, directing submissions down different routes based on specific conditions, without requiring user interaction.

Purpose

The Condition task is designed to:

  • Create branching paths in workflows based on submission data
  • Implement business rules for automated decision-making
  • Route workflows differently based on specific criteria
  • Enable dynamic workflow behavior without custom code
  • Automate decisions that would otherwise require manual evaluation

Adding a Condition Task to Your Workflow

Basic Setup

  1. In the Workflow Builder, drag the Condition task from the task palette onto the canvas
  2. Click on the Condition task to open its configuration panel
  3. Configure the following required settings:
    • Conditions to be fulfilled: Enter the logical expression that will be evaluated
    • Title for process: Enter a descriptive title that will appear in the submission history
    • Label for status: (Optional) Override the default status label

Condition Expression

The condition expression is a logical statement that evaluates to either true or false:

  • Use standard PHP comparison operators (==, !=, <, >, <=, >=)
  • Reference form fields using their property names
  • Use logical operators (&&, ||, !) for complex conditions
  • For supplementary forms, use "forms.N.field_name" (e.g., "forms.2.amount")

Examples of valid conditions:

  • amount > 1000 (Routes differently if amount exceeds 1000)
  • department == "IT" (Routes differently based on department)
  • forms.1.approved == true && amount < 5000 (Combines multiple conditions)
  • risk_score >= 75 || expedited == true (Uses OR logic)

Workflow Branching

In the workflow builder canvas, the Condition task creates two output connectors:

  • The right connector represents the path taken when the condition is true
  • The left connector represents the path taken when the condition is false

You can connect different tasks to each of these connectors to create branching paths in your workflow. The workflow will automatically follow the appropriate path based on the condition evaluation.

Sub-Workflow Triggering (Optional)

Some condition tasks may have an additional option:

  • Workflow to trigger when condition is met: Select a workflow to trigger as a sub-workflow
  • This option allows you to launch a separate workflow when the condition is true
  • The main workflow will continue along its path regardless of the sub-workflow

Advanced Settings

Visibility Settings

  • Hide from submission history: When checked, prevents this condition task from appearing in the submission history
    • Useful for keeping the submission history focused on user actions
    • The condition evaluation still occurs, but isn't visible in the history
    • Helps reduce clutter in complex workflows with many tasks

How Condition Tasks Work

When a workflow reaches a Condition task:

  1. The system retrieves the condition expression from the task configuration
  2. Any placeholders in the condition are replaced with actual values from the submission data
  3. The condition is evaluated to either true or false using PHP's eval function
  4. Based on the result:
    • If true, the workflow follows the "right" branch
    • If false, the workflow follows the "left" branch
  5. The workflow automatically proceeds to the next task on the selected branch
  6. If a sub-workflow is configured and the condition is true, the sub-workflow is also triggered

Unlike action tasks (Approve, Review, Process), Condition tasks:

  • Do not appear in users' task lists
  • Do not require any user action to complete
  • Execute automatically and immediately
  • Control workflow routing based on data-driven decisions

Use Cases

Amount-Based Routing

Route workflows based on monetary values:

  • Send high-value purchases to senior management for approval
  • Route different expense categories to appropriate departments
  • Apply different approval processes based on budget impact
  • Implement multi-tier approval thresholds

Risk-Based Routing

Implement risk-based decision making:

  • Route high-risk submissions for additional review
  • Apply different validation requirements based on risk scores
  • Implement enhanced due diligence for certain scenarios
  • Skip unnecessary steps for low-risk submissions

Department-Specific Processes

Create department-specific workflow branches:

  • Route IT requests to the IT department
  • Send HR-related submissions through HR-specific processes
  • Apply different approval requirements by department
  • Implement department-specific validation rules

Status-Based Decisions

Route based on previous task outcomes:

  • Create different paths for approved vs. rejected submissions
  • Implement special handling for exceptions
  • Route based on review feedback
  • Apply different processes based on submission quality

Parallel Processing

Trigger sub-workflows while continuing the main process:

  • Start notification workflows while continuing the main approval process
  • Initiate background checks while proceeding with application processing
  • Begin document preparation while continuing review processes
  • Launch audit trails while proceeding with the main workflow

Best Practices

  1. Clear condition expressions: Write conditions that are easy to understand and maintain
  2. Descriptive task titles: Use titles that clearly indicate the decision being made
  3. Consistent branching: Use consistent conventions for true/false routing (e.g., always use right for approval paths)
  4. Error handling: Consider what happens if referenced fields are missing or null
  5. Testing: Test conditions with different data scenarios to ensure they route as expected
  6. Documentation: Document complex conditions for future reference
  7. Field validation: Ensure that fields referenced in conditions will contain appropriate data types

Troubleshooting

Unexpected Routing

If workflows are not routing as expected:

  • Verify that the condition expression is correctly written
  • Check that referenced fields exist in the submission data
  • Test the condition with different values to understand its behavior
  • Ensure that both branches are properly connected to subsequent tasks
  • Check for typos in field names (they are case-sensitive)

Syntax Errors

If the condition task fails due to syntax errors:

  • Check for proper syntax in the condition expression
  • Ensure string values are properly quoted
  • Verify that field names are correctly referenced
  • Test simpler versions of the condition to isolate the issue
  • Look for missing parentheses or operators

Missing Field References

If the condition references fields that don't exist:

  • Verify the exact field names in your forms
  • For supplementary forms, ensure the form sequence number is correct
  • Check for typos in field names
  • Consider adding default values to forms to handle missing data
  • Use the system logs to identify specific error messages

Sub-Workflow Issues

If sub-workflows aren't being triggered:

  • Verify that the selected workflow exists and is active
  • Check that the condition is evaluating to true
  • Ensure the sub-workflow is properly configured
  • Check the system logs for any errors during sub-workflow triggering
  • Transform Tasks: Prepare data before condition evaluation
  • Hook Tasks: Alternative for more complex conditional logic
  • Multiple Conditions: Chain multiple condition tasks for complex decision trees
  • Sub-Workflows: Create modular workflow components that can be triggered conditionally

Summary

The Condition task is a powerful component in OSPROV's workflow builder that enables dynamic, data-driven routing of workflows. By strategically placing condition tasks in your workflows, you can implement business rules, create branching paths, and automate decisions that would otherwise require manual evaluation.

Unlike action tasks that require user interaction, condition tasks execute automatically and control workflow routing based on data evaluation. This makes them ideal for implementing business rules, creating different processes based on submission characteristics, and automating routine decisions throughout your business processes.