Switch Node

From FojiSoft Docs
Revision as of 23:10, 5 March 2025 by Mitchell.Hirsche (talk | contribs) (Mitchell.Hirsche moved page Documentation: Switch Node to Switch Node)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Switch node in Pathways is used to evaluate an expression and execute one of multiple defined branches based on the result. Each branch represents a possible case for the evaluated expression.

Node Name

  • Name: Assign a unique and descriptive name to the Switch node for identification purposes.

Configuration

  1. Expression
    • Type an expression that the node will evaluate.
    • Expression Type:
      • Script: Use JavaScript or similar scripting logic for complex computations.
      • Handlebars Template: Use Handlebars syntax for templating expressions, often useful for simple conditional logic.
    • This field is required.
  2. Cases
    • Add cases that represent the possible outcomes of the expression evaluation.
    • Each Case:
      • Must be named (e.g., "Case 1," "Case 2").
      • Should define the condition to match the result of the expression.
  3. Default Case
    • If none of the defined cases match, the default branch will execute. You must specify this as the fallback logic.

Behavior

  • The Switch node evaluates the given expression and matches it against the conditions specified in the cases.
  • Only the branch corresponding to the matching case is executed. If no cases match, the default case is executed.

Example Use Case

If you need to route tasks based on user roles or system states, the Switch node can be configured to execute different workflows for "Admin," "User," and "Guest."

Steps to Configure

  1. Name the Switch node for easy identification.
  2. Define the Expression using either Script or Handlebars Template based on the complexity of your logic.
  3. Add branches under Cases, specifying their names and respective conditions.
  4. Add a default case to handle unmatched scenarios.

This setup ensures dynamic task execution based on evaluated results, providing flexibility in your workflows.