🌲 Multi-Path Node

The Multi-Path Node is a type of `condition` node that evaluates multiple filters in sequence. The first filter that evaluates to `true` determines which path (edge) to follow in the diagram.

For more information on JSON logic Click here

This node allows you to build multi-branch conditional logic, where a single node can route to different outcomes based on priority-ordered criteria.


πŸ“¦ JSON Representation

{
  "type": "condition",
  "data": {
    "id": "multi-path",
    "formData": {
      "filters": [
        {
          "id": "filter_1",
          "data": {
            "and": [
              {
                "<=": [
                  { "var": "effective_at" },
                  { "var": "deal.$close_date__12_months" }
                ]
              },
              {
                "==": [
                  { "var": "deal.stage" },
                  "Won"
                ]
              }
            ]
          }
        },
        {
          "id": "filter_2",
          "data": {
            "==": [
              { "var": "deal.stage" },
              "Lost"
            ]
          }
        }
      ]
    },
    "type": "condition"
  }
}

🧾 Form Data Fields

FieldTypeRequiredDescription
filtersArray of { id: string, data: object }βœ…A list of JSON logic filters. The node evaluates each filter in order and selects the first one that returns true.

Each filter object must have:

  • id: A unique string identifier for the filter.
  • data: A JSON Logic object to evaluate.

βš™οΈ Execution Logic

  1. Iterate Through Filters:
  • Filters are evaluated in the order they are defined in the array.
  1. Preprocess Fields:
  • For each filter: load custom fields, metrics, and targets using loadUserFields and loadMetricAndTargetValues.
  1. Evaluate Logic:
  • If the JSON logic expression (filter.data) returns true, the index of the filter is returned and used to follow the corresponding edge in the diagram.
  1. No Match:
  • If no filter returns true, the function returns -1. This typically results in no edge being followed (or an error if all branches are required).

πŸ”’ Output

  • Returns the index of the first filter (starting at 0) that evaluates to true.
  • This index corresponds to the correct edge to follow in the node's connections.

βœ… Validation Rules

RuleDescription
Filters must be definedformData.filters must exist and be an array.
Each filter must contain logicEach filter.data must be a valid, non-empty JSON object.
Each filter must have valuesThe logic must include at least one actual condition with non-empty value arrays.

πŸ§ͺ Example Logic

{
  "filters": [
    {
      "id": "high_value_won",
      "data": {
        "and": [
          {
            ">": [{ "var": "deal.amount" }, 10000]
          },
          {
            "==": [{ "var": "deal.stage" }, "Won"]
          }
        ]
      }
    },
    {
      "id": "fallback",
      "data": {
        "==": [{ "var": "deal.stage" }, "Closed"]
      }
    }
  ]
}
  • If the deal is "Won" and amount > 10,000 β†’ path 0.
  • If the deal stage is "Closed" β†’ path 1.
  • Otherwise β†’ -1 (no match).

On this page