Switch Function

Satish V
Satish V
  • Updated

The Switch function allows us to set a value based on the filters and also to branch out to different paths based on the configured cases during execution of the pipeline.

Switch Function is available for both entity and field pipelines in the functions section of the pipeline.

Quick Start and Node logging are supported for Switch Function.

Components of Switch Function:

  • Case
    • Users can configure any number of cases. Every case will have the following inputs as mandatory.
      • Case Name
      • Data Type
      • Multi-valued
      • Value
      • Filters
      • Do not match on blank values
    • Cases are evaluated sequentially and is labeled by number. You can change the order of the cases by clicking the up and down arrow or by dragging the drag handles up or down.

  • Default Case
    • Default cases will always exist, and cannot be deleted.
    • Case Name for Default case is Default and cannot be modified.
    • Default case will have the following inputs.
      • Data Type
      • Multi-valued
      • Value

How does Switch function evaluation work ?

  • Every case configured will be evaluated sequentially based on the following (ordered by number).
    • Configured filter will be evaluated
    • If the filter evaluates to true, then the value configured as part of that case will be set as the value of that function. Format : {{Value From <Node Name>}}
    • Once a case’s filter gets evaluated to true, the case evaluation will stop.
  • If none of the configured cases gets evaluated to true, then the default case’s value will be set as the value of the function.

How does Switch function branching work ?

  • An implicit node will automatically be added when you drag and drop an edge from a Switch function node to the next node. This node will work like a drop down with following values.
    • {All the case names configured in the switch function}
    • Default
    • Any
  • During run time, only the path with the case name that got evaluated to true in the Switch function will be allowed to proceed.
  • Any is a special value that will be listed as part of the options in the Switch function's branch node.
    • Any will represent the cases that are configured as part of the Switch function but do not have a branch specified for it (including default case).
    • For example, in the below example we have three cases(case1, case2, case3) and a default configured but we only have two branch options(for case1 and case2). Then Any path will be executed if case3 or default case gets evaluated to true.

 

Validations:

  • Custom cases are not allowed to have the case name as “Default”
  • Case names should be unique within the scope of a Switch function.
  • It is not required that all cases configured should have an outgoing path.
  • One case can have only one outgoing path from the Switch function.
  • If Multi-valued is chosen, then the expected value should be a json array of the chosen datatype.
    • Example:
      • Text type : ["value1", "value2"]
      • Integer type : [1, 2]

Pattern to refer the value getting set in the Switch function node :  {{Value From <Node Name>}}

Share this

Was this article helpful?

0 out of 0 found this helpful