Articles in this section

Transformation 1.0 rules

Transformation 1.0 (Rules 1.0 in the Define transformation editor) restructures records with a list of rules, each of which copies an input field to an output field path. Use it to rename fields, remove fields you don't need, flatten nested data, and combine arrays. Rules 1.0 is available on exports, lookups, and import results. This article explains how Rules 1.0 builds its output, how to add rules, and four worked examples.

How Rules 1.0 builds the output

Rules 1.0 builds each output record only from your rules. A field appears in the output only if a rule includes it.

  • To keep a field unchanged, add a rule that maps it to the same name.
  • To remove a field, leave it out of the rules.
  • To rename a field, map it to a new output name.

Each rule has two fields:

  • extract — The path of the input field, for example owner.name or items[*].price.
  • generate — The output path to write the value to, for example ownerName or products[*].price.

Use [*] in a path to apply the rule to every item in an array. Paths are case-sensitive: a rule for items[*].name doesn't match an input field named Items or Name.

Add Rules 1.0 rules

  1. Open the Define transformation editor on the step. For steps, see Add a transformation to a flow step.
  2. Select Rules 1.0.
  3. For each field you want in the output, add a rule: enter the input path in extract, enter the output path in generate, and then select Add to add the next row.
  4. With Rules 1.0 selected, preview and save the transformation. For the steps, see Preview and save.

Example: Rename fields and remove the rest

This example keeps two fields from a reminder record, renames them, and drops everything else.

Input:

{
  "id": "Rm04B1UDQBJ6",
  "creator": "U024LNKGZMK",
  "text": "Follow up with the customer",
  "user": "U024LNKGZMK",
  "recurring": false,
  "time": 1668609000,
  "complete_ts": 0,
  "recurrence": null,
  "item": null
}

Rules:

extract (input) generate (output)
id resourceId
user userId

Output:

{
  "resourceId": "Rm04B1UDQBJ6",
  "userId": "U024LNKGZMK"
}

Example: Merge two arrays into one list of objects

When a record holds related values in separate arrays, you can merge them into one array of objects. Items at the same position in each array are combined into one object.

Input:

{
  "itemNames": ["item1", "item2", "item3"],
  "prices": [10, 20, 30]
}

Rules:

extract (input) generate (output)
itemNames[*] items[*].name
prices[*] items[*].price

Output:

{
  "items": [
    { "name": "item1", "price": 10 },
    { "name": "item2", "price": 20 },
    { "name": "item3", "price": 30 }
  ]
}

Example: Repeat a parent field for each array item

You can turn an array into a list of objects that each carry a value from the parent record. Write the output to *.<field> to produce a top-level array.

Input:

{
  "id": 100,
  "items": [
    { "name": "Item1", "price": 10 },
    { "name": "Item2", "price": 20 },
    { "name": "Item3", "price": 30 }
  ]
}

Rules:

extract (input) generate (output)
id *.id
items[*].name *.name
items[*].price *.price

Output:

[
  { "id": 100, "name": "Item1", "price": 10 },
  { "id": 100, "name": "Item2", "price": 20 },
  { "id": 100, "name": "Item3", "price": 30 }
]

Important: A top-level array output doesn't split into separate records. The next step receives one record that contains the whole array.

Example: Flatten an array within an array

When each item in an array contains its own array, you can produce one flat list with an entry for every inner item. Fields from the outer item repeat on each entry.

Input:

{
  "items": [
    {
      "name": "perfume",
      "price": 50,
      "flavors": [
        { "weight": 3.14, "scent": "Obsession", "color": "Black" },
        { "weight": 3.41, "scent": "Cool waters", "color": "Black" }
      ]
    }
  ]
}

Rules:

extract (input) generate (output)
items[*].name products[*].name
items[*].price products[*].price
items[*].flavors[*].weight products[*].weight
items[*].flavors[*].scent products[*].scent
items[*].flavors[*].color products[*].color

Output:

{
  "products": [
    { "name": "perfume", "price": 50, "weight": 3.14, "scent": "Obsession", "color": "Black" },
    { "name": "perfume", "price": 50, "weight": 3.41, "scent": "Cool waters", "color": "Black" }
  ]
}