Loopfour
Blocks

Transform block

Configure the Transform block to map and reshape fields from earlier steps into the structure that a later step or system expects.

The Transform block (type: "transform") reshapes a list of records: it can pick and rename fields from each record, or keep only the records that pass a simple test. For the plain-language guide, see Reshape data between systems.

When to use it

  • Turn a list of CRM deals into a list of { customer, amount } records for an invoicing step.
  • Keep only the invoices with a balance above a threshold.

For anything beyond renaming fields and a single comparison, such as totals, grouping or date arithmetic, use the Code block.

Configuration

The executor reads these fields:

Field (config key)TypeRequiredMeaning
operationmap or filterYesWhat to do with data. Any other value returns data unchanged.
dataarrayYesThe records, usually a whole template reference such as {{steps.list_deals.results}}.
mappingobjectFor mapOutput field name to a dot path in each record, such as { "customer": "properties.company", "amount": "properties.amount" }. A path that does not exist gives an empty value.
conditionstringFor filterOne comparison in the form field operator value, such as amount_due > 1000. field is a top-level field name (letters, digits and underscores). Operators: ==, !=, >, <. > and < compare as numbers; == and != compare as text. A condition that does not match the form keeps every record.

The editor shows Transformation Code (code) and Input Data (input). The current executor does not run code, so a step with only those fields returns no value. To run JavaScript, use the Code block.

Output

The step's output is the resulting list itself, not an object:

OperationOutput
mapA list of new records with only the mapped fields.
filterThe records that passed condition, unchanged.

Read the whole list as {{steps.<step id>}}, for example as the data of another Transform step or inside a Code step's input. A Loop collection needs a path below the step id, so it cannot take this output directly. The editor's output list shows result; the executor does not wrap the list in that field.

Example

This workflow lists Stripe invoices, keeps those with more than $1,000 due, and maps them to the fields a reminder step needs.

{
  "name": "Large open invoices",
  "trigger": { "type": "api" },
  "steps": [
    {
      "id": "list_invoices",
      "type": "action",
      "name": "List open invoices",
      "action": "stripe.listInvoices",
      "config": { "status": "open", "limit": 100 }
    },
    {
      "id": "over_1000",
      "type": "transform",
      "name": "Keep invoices over $1,000 due",
      "config": {
        "operation": "filter",
        "data": "{{steps.list_invoices.data}}",
        "condition": "amount_due > 100000"
      }
    },
    {
      "id": "reminder_rows",
      "type": "transform",
      "name": "Map to reminder fields",
      "config": {
        "operation": "map",
        "data": "{{steps.over_1000}}",
        "mapping": {
          "invoiceNumber": "number",
          "customerEmail": "customer_email",
          "amountDueCents": "amount_due",
          "dueDate": "due_date"
        }
      }
    }
  ]
}

Stripe amounts are in cents, so the filter compares against 100000.

Errors and limits

  • data that is not a list, or a missing mapping or condition, returns data unchanged rather than failing.
  • condition supports one comparison on a top-level field. >= and <= are not supported: the value is then read as = <number>, which is not a number, so no record passes.
  • reduce is accepted as an operation but returns data unchanged.

On this page