Transform Data step

Filter, map, sort and group a list without writing a script.

The Transform Data step reshapes a list without writing a script. You build a pipeline of operations (filter, map, sort, group and so on), and each one works on the result of the one before.

Set it up

In the appdata fieldWhat it does
SourcesourceThe variable or dot path holding the list, like orders.items or order.line_items. A variable holding JSON text is parsed for you.
OperationsoperationsThe steps of the pipeline, in order. Select Add operation, and drag to reorder.
Response variableresponse_variableSaves the result.

Operations

OperationopSettingsResult
FilterfilterField, Operator, ValueKeeps the items that match.
MapmapFields: one name: path per lineNew objects with just those fields, renamed.
PickpickKeep: one path per lineEach item with only those paths. A nested path like customer.email becomes a flat key customer.email.
SortsortField, DescendingThe list in order.
Groupgroup_byFieldAn object of lists, keyed by the field's value.
SumsumFieldA number.
CountcountA number.
LimitlimitLimit (n)The first n items. Always set n.
UniqueuniqueFieldThe first item for each value of the field. Leave Field blank to compare whole items.
FirstfirstThe first item, or null if the list is empty.

Filter operators are Equals, Not equals, Greater than, Greater than or equal, Less than, Less than or equal, Contains, Is in, Exists and Does not exist.

  • Value can use Liquid, like {{ store_id }}.
  • Is in takes a comma-separated list (open, pending) or a JSON array.
  • Contains matches text without caring about case, or checks whether a list contains the value.
  • Numbers are compared as numbers, so "5" equals 5.
  • If some items may not have the field at all, add an Exists filter first, so you know exactly which items you're comparing.

Fields and paths use dots for nesting, like customer.email or lines.0.sku.

Example 1: Keep a webhook order's line items

Trigger: Webhook.

  1. Script: Read the order: $.order = JSON.parse($.default);
  2. Transform Data: Keep the line items, Source order.line_items, Response variable lines, with operations:
    1. Filter: Field quantity, Greater than, 0

    2. Map: Fields

      sku: sku
      qty: quantity
      price: price

$.lines is now a tidy list like [{"sku": "TEE-RED-M", "qty": 2, "price": "25.00"}], ready for a Loop or a request body.

Example 2: Export open order lines

Trigger: Scheduled.

  1. Shopify GraphQL: Fetch every order page, with Fetch all pages on, Response variable orders.
  2. Transform Data: Keep the open lines, Source orders.items, Response variable open_orders, with operations:
    1. Filter: Field displayFulfillmentStatus, Is in, UNFULFILLED, PARTIALLY_FULFILLED
    2. Sort: Field createdAt
    3. Pick: Keep name, createdAt, displayFulfillmentStatus
  3. File: Write the export, Source open_orders. See File.

Tips

  • Reach for a Script when it gets clever. Transform Data is great for filter-sort-pick. Calculations across fields are easier in a Script.
  • Count and Sum end the list. They return a number, so put them last.
  • Test with Run. The response variable shows in the job's variables, so you can check the result before wiring up the next step.

← All Glue step guides


Did this page help you?