Skip to main content

Transform data with JavaScript

A transformation is a snippet of JavaScript that runs on an order or shipment as it flows through Orderly. Use one to tag orders, rewrite fields, normalize data from a messy source, or enrich records before they are exported. Manage them under Transformations.

When a transformation runs

Each transformation is bound to one trigger point:

Trigger pointRuns on
Order IngestOrders as they sync in from a bridge
Order ExportOrders as they are pushed out to a destination
Shipment IngestShipments as they sync in
Shipment ExportShipments as they are pushed out

You can also scope a transformation to a single bridge or leave it on All Bridges. When several transformations share a trigger point, they run in priority order (lowest number first).

Write one

Click New Transformation and give it a name, description, trigger point, and bridge. Then write the code.

Your snippet receives the record as data, mutates it, and returns it:

// Available: data (the order/shipment object)
// Return the modified data

if (data.totals?.total > 100) {
data.tags = data.tags || [];
data.tags.push('high-value');
}

return data;

The editor helps you write against the real shape of the data:

  • A field reference panel on the left lists every field on the order or shipment model (customer, addresses, totals, line items, and more), grouped and searchable. Click a field to insert its path, for example data.totals.total, at your cursor. Hover for its type and description.
  • The panel switches to the Shipment model automatically for shipment-triggered transformations.

Test before you save

Under Test with Real Data, look up a real record by order number, tracking number, or ID, then click Run Test. Orderly runs your code in a sandbox against that record and shows the transformed output (or an error) plus how long it took. Use it to confirm a transformation does what you expect before it touches live data.

Next steps