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 app | data field | What it does |
|---|---|---|
| Source | source | The variable or dot path holding the list, like orders.items or order.line_items. A variable holding JSON text is parsed for you. |
| Operations | operations | The steps of the pipeline, in order. Select Add operation, and drag to reorder. |
| Response variable | response_variable | Saves the result. |
Operations
| Operation | op | Settings | Result |
|---|---|---|---|
| Filter | filter | Field, Operator, Value | Keeps the items that match. |
| Map | map | Fields: one name: path per line | New objects with just those fields, renamed. |
| Pick | pick | Keep: one path per line | Each item with only those paths. A nested path like customer.email becomes a flat key customer.email. |
| Sort | sort | Field, Descending | The list in order. |
| Group | group_by | Field | An object of lists, keyed by the field's value. |
| Sum | sum | Field | A number. |
| Count | count | A number. | |
| Limit | limit | Limit (n) | The first n items. Always set n. |
| Unique | unique | Field | The first item for each value of the field. Leave Field blank to compare whole items. |
| First | first | The 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"equals5. - 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.
- Script: Read the order:
$.order = JSON.parse($.default); - Transform Data: Keep the line items, Source
order.line_items, Response variablelines, with operations:-
Filter: Field
quantity, Greater than,0 -
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.
- Shopify GraphQL: Fetch every order page, with Fetch all pages on, Response variable
orders. - Transform Data: Keep the open lines, Source
orders.items, Response variableopen_orders, with operations:- Filter: Field
displayFulfillmentStatus, Is in,UNFULFILLED, PARTIALLY_FULFILLED - Sort: Field
createdAt - Pick: Keep
name,createdAt,displayFulfillmentStatus
- Filter: Field
- 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.
Updated about 23 hours ago
Did this page help you?
