Zetect Expressions & Transforms Back to zetect.inSwitch portal ⇄

Chaining Transforms

A pipeline runs a list of transforms in order and hands each result to the next step. Use it to clean a value up, map it and format it in one definition. Pipelines can be nested up to 20 levels deep.

Applies to

Anywhere you can choose Transform. See Where They Are Used.

Limits

Pipelines and if branches nest up to 20 levels deep.

How values flow through a pipeline

  1. The first step usually names its value with input, for example "input": "${department}".
  2. Each later step that has no input works on the previous step's result.
  3. A step that has its own input uses that and ignores the previous result.
  4. The pipeline returns the last step's result.
Step typeUses the previous result?
uppercase, lowercase, trim, replace, split, regex, lookup, date-format, date-addYes, when the step has no input.
mathYes, as the left operand, when the step has neither left nor input.
ifIts condition doesn't, but the chosen then or else branch receives it.
pipelineYes. A nested pipeline's first step receives the outer pipeline's current value.
concat, decision, static, uuid, current-dateNo. They build their value from their own options, so the previous result is discarded.

Building a pipeline

To chain transforms in a mapping:

  1. In the mapping row, choose Transform as the Source.
  2. After Insert:, select pipeline to start from the starter definition.
  3. Give the first step an input that names the attribute to start from.
  4. Add later steps without an input so each works on the result before it.
  5. End with the step that produces the final form, often a lookup with a default.
  6. Save the mappings.

Example: normalise, then map

Department values arrive with stray spaces and mixed case. Trim and upper-case them before looking up the organisational unit.

{
  "type": "pipeline",
  "steps": [
    { "type": "trim", "input": "${department}" },
    { "type": "uppercase" },
    { "type": "lookup",
      "mapping": { "IT": "OU=IT,DC=example,DC=com",
                   "FINANCE": "OU=Finance,DC=example,DC=com" },
      "default": "OU=Users,DC=example,DC=com" }
  ]
}

department = " it "     → IT      → OU=IT,DC=example,DC=com
department = "Finance"  → FINANCE → OU=Finance,DC=example,DC=com
department = "Legal"    → LEGAL   → OU=Users,DC=example,DC=com

Example: build, then clean up

Because concat ignores the previous result, put it first and clean up after it.

{
  "type": "pipeline",
  "steps": [
    { "type": "concat", "values": ["${firstName}", ".", "${lastName}"] },
    { "type": "lowercase" },
    { "type": "replace", "search": " ", "replace": "" }
  ]
}

firstName = "Anna Maria", lastName = "De Souza"
→ Anna Maria.De Souza → anna maria.de souza → annamaria.desouza

Example: branch on an attribute

An if step passes the current value into whichever branch it picks, so a branch can keep transforming it. Here contractors get a c- prefix on their login name.

{
  "type": "pipeline",
  "steps": [
    { "type": "split", "input": "${email}", "delimiter": "@", "index": 0 },
    { "type": "lowercase" },
    { "type": "if",
      "when": { "employeeType": "Contractor" },
      "then": { "type": "regex", "pattern": "^", "replacement": "c-" },
      "else": { "type": "trim" } }
  ]
}

email = "Priya.Sharma@example.com", employeeType = "Employee"
→ Priya.Sharma → priya.sharma → priya.sharma
email = "Ravi.Kumar@example.com", employeeType = "Contractor"
→ Ravi.Kumar → ravi.kumar → c-ravi.kumar

Troubleshooting

  • The pipeline returns no value. A step returned no value and the steps after it had nothing to work on. A step with no input as the first step of a top-level pipeline also has nothing to work on. Give the first step an input.
  • An earlier step seems to be ignored. A later step has its own input, or is a type that ignores the previous result, such as concat.
  • A step's options can't refer to the current value. Tokens read attributes only. Steps receive the current value only as their input.