πŸ§ͺ Filter Node

The Filter Node is a type of `condition` node that evaluates a set of filters (expressed in `JSON Logic`) against the input data. If the filter conditions pass, the node returns `true`, allowing the execution flow to continue; otherwise, it returns `false`.

For more information on JSON logic Click here

πŸ“¦ JSON Representation

{
  "type": "condition",
  "data": {
    "id": "filter",
    "formData": {
      "filters": {
        "and": [
          {
            "<=": [
              { "var": "effective_at" },
              { "var": "deal.$close_date__12_months" }
            ]
          },
          {
            "==": [
              { "var": "deal.stage" },
              "Won"
            ]
          }
        ]
      }
    },
    "type": "condition"
  }
}

🧾 Form Data Fields

FieldTypeRequiredDescription
filtersJSON objectβœ…A JSON Logic object that defines the rules to evaluate against the data record. Filters can include nested logical operators like and, or, comparison operators like ==, >=, etc., and variable references (e.g. deal.$amount).

βš™οΈ Execution Logic

When the node is processed:

  1. Field Preprocessing:
  • The node loads any user-defined fields, metrics, and targets referenced in the filters using loadUserFields and loadMetricAndTargetValues.
  1. Evaluation:
  • The filter logic is evaluated using a JSON logic engine. The result is a single boolean:
  • true β†’ the filter passed and the flow continues to the next node.
  • false β†’ the filter failed and the flow stops or diverges based on diagram logic.
  1. Output:
  • Returns a single boolean value.

βœ… Validation Rules

During diagram validation, the following checks are enforced:

RuleDescription
Filters must be definedThe filters field must exist.
Filters must not be emptyAt least one logical condition must be present.
Filters must include valuesJSON logic must include actual conditions with values or variables.

πŸ§ͺ Example: Filter Logic

Here’s what the logic from the JSON above means:

{
  "and": [
    {
      "<=": [
        { "var": "effective_at" },
        { "var": "deal.$close_date__12_months" }
      ]
    },
    {
      "==": [
        { "var": "deal.stage" },
        "Won"
      ]
    }
  ]
}

This filter will pass (return true) if:

  • The effective_at date is before or equal to deal.$close_date__12_months, and
  • The deal stage is "Won".

On this page