younifyd
Menu

Map Fields

Map fields from source data to a new target shape using structured field mappings, built-in transforms, and array-to-array mapping.

Use it in a workflow

  1. Add a step and choose the Mapper connector.
  2. Pick the Map Fields action (under data).
  3. Fill in the fields below, then reference the result from later steps as {{mapFields.response.data}}.

Fields

datastringrequired

The JSON data to map (object, array, or a JSON string). Can reference previous steps, e.g. {{trigger.body}}.

eachItemOfstring

Optional. A path to a list in the input data, such as products. The mappings are then written for one item of that list, with paths relative to it, and run for every item. The result is the list of what they produced, in the same order. Leave empty to run the mappings once over all the input.

mappingsarray<object>required

Define how source fields map to target fields. An 'Array Group' produces a list in the output, one entry per source item. An 'Object Group' produces a single nested object built from its child fields.

kindstringrequired

Pick by what the OUTPUT needs. 'field': one value. 'arrayGroup': a LIST in the output, one entry per item of a source list — requires sourcePath, and child paths in `mappings` are relative to each item. 'objectGroup': ONE nested object in the output, built from the child mappings in `mappings` — sourcePath is optional, and blank means the children read from the whole payload. A list is never an objectGroup and a single object is never an arrayGroup.

One offieldarrayGroupobjectGroupDefault "field"

mappingsarray<object>

Required on arrayGroup and objectGroup — the mappings applied inside the group. Omit on a plain field.

sourcePathstring

Dot path to read, e.g. order.items[0].sku. Special references: $index (0-based) / $row (1-based) position in the current list, $parent.<path> the enclosing item, $root.<path> the whole payload, $group (every item of the current group; $group[*].qty is all their qty values), $output.<path> what earlier rules already wrote. `[*]` reads a field from every item of a list, e.g. rows[*].qty. On an Object Group, blank means the children read from the current scope.

sourceTypestring

'path' (default) reads sourcePath. 'static' writes staticValue as-is (any JSON value) — use it for constants instead of a blank path.

One ofpathstatic

staticValueany

The constant to write when sourceType is 'static'. May be a string, number, boolean, object or array. May contain {{references}} such as {{step.response.data}} or {{variables.key}}; for an object/list, put the reference where a JSON value goes, e.g. {"items": {{step.response.data.items}}}, and store the whole value as a string with staticType 'json'.

staticTypestring

How to read staticValue when it holds text: 'text' (default), 'number', 'boolean', or 'json' (parse the text into an object/list after references are filled in).

One oftextnumberbooleanjson

transformsarray<object>

Applied in order, each receiving the previous result. Each is {kind:'builtin', name, params} or {kind:'jsonata', expression}. Built-ins — toNumber: text → number; toString: any value → text; toBoolean: true/1/yes → true, false/0/no → false; trim: remove spaces at both ends; uppercase: UPPERCASE text; lowercase: lowercase text; dateFormat {inputFormat?: "auto" (default, ISO dates) | "excelSerial" | a pattern such as "DD/MM/YYYY", outputFormat: pattern of YYYY MM DD HH mm ss}: re-write a date; defaultValue {value}: use a fallback when the value is missing or empty text; split {delimiter}: text → list; join {delimiter}: list → text; round {precision}: round a number; concat {sources: [paths], delimiter?}: this value followed by other fields; substring {start?, length?}: part of a text; replace {pattern, replacement?, flags?}: find and replace in text (regular expression); toJsonString {pretty?}: object/list → JSON text; parseJson: JSON text → object/list; sum {field?, multiplyBy?} — multiplyBy sums field × multiplyBy per item (e.g. price × qty): total of a list of numbers; count: how many items in a list; min {field?}: smallest number in a list; max {field?}: largest number in a list; average {field?}: average of a list of numbers; distinct {field?}: unique values of a list; lookup {table: {"key": "value"}, default?, caseInsensitive?}: swap a value using a table; unmatched values pass through unless a default is given; calculate {operation: "add"|"subtract"|"multiply"|"divide", value: number} or {operation, valuePath: "other.field"}: arithmetic on the value; template {template: "PO-{order.id}-{$row}"} — {path} inserts a field, {value} the previous result: build text from fields; needs no sourcePath.

groupByarray<string>

arrayGroup only. One output entry per distinct combination of these item paths. Inside, the item is the group's first member and $group holds all members; nest another arrayGroup with sourcePath '$group' to group within a group.

sortBystring

arrayGroup only. Item path to sort by before grouping/mapping.

sortDirectionstring

One ofascdesc

filtersarray<object>

arrayGroup only. Keep items matching ALL of these: {path, operator: equals|notEquals|greaterThan|greaterThanOrEqual|lessThan|lessThanOrEqual|contains|exists|notExists, value}.

targetPathstringrequired

Dot path to write. Use $ inside an arrayGroup's children to make the result the whole list entry (a list of lists, or of plain values).

optionsobject
onValidationErrorstring

One ofhaltcollectDefault "halt"

errorResponseobject3 fields

Configure the response when validation fails in halt mode. If not provided, a default error response is used.

Examples

Reshape a webhook payload

Map a subset of an incoming order payload into a flatter shape, converting price to a number and defaulting a missing currency

json
{
  "data": "{\"order\": {\"id\": \"abc123\", \"amount\": \"42.50\"}}",
  "mappings": [
    {
      "kind": "field",
      "id": "id",
      "sourcePath": "order.id",
      "targetPath": "orderId"
    },
    {
      "kind": "field",
      "id": "amount",
      "sourcePath": "order.amount",
      "targetPath": "total",
      "transform": {
        "kind": "builtin",
        "name": "toNumber"
      }
    },
    {
      "kind": "field",
      "id": "currency",
      "sourcePath": "order.currency",
      "targetPath": "currency",
      "transform": {
        "kind": "builtin",
        "name": "defaultValue",
        "params": {
          "value": "USD"
        }
      }
    }
  ]
}

Need more? See the Mapper guide for connection setup and behaviour shared by every action.

Was this page helpful?