Metafield triggers by resource typeDraft order metafield trigger

Draft order metafield trigger

Copy page

Start a Shopify Flow workflow when a draft order metafield changes. Track it in Workflow Trigger Extensions and get the old and the new value.

A sales team works with quotes as draft orders and keeps the stage in the draft order metafield Quote status (custom.quote_status). When a quote moves to approved, the person who sends the invoice should be told.

This page shows how to start a Shopify Flow workflow whenever a metafield of a draft order changes, with Workflow Trigger Extensions. The steps are the same for every metafield of this resource type; the example uses Quote status (custom.quote_status).

What you need

  • A metafield definition. Create it in your Shopify admin under Settings > Metafields and metaobjects > Draft orders. A metafield without a definition cannot be tracked.
  • The permission Draft Order Data Access. Grant it on the app's Permissions page, see Permissions and data access.

1. Track the metafield

  1. Open Metafield Triggers in the app and click Add trigger.
  2. Choose the resource type Draft Order.
  3. Tick the metafield, here Quote status. You can tick several at once or use Select all.
  4. Click Add trigger.

To track every metafield of this resource type, including the ones you create later, choose All metafields instead of ticking single ones, then click Track all metafields.

The Add Metafield Trigger dialog with resource type Draft Order and the metafield Quote status, custom.quote_status, ticked
Resource type Draft Order, the metafield ticked. All metafields tracks every metafield of the type instead.

The new trigger shows Initializing while the app reads the current value of the metafield on your existing draft orders, then Active. That first reading is why the very first change already arrives with the right previous value.

If the metafield is missing from the list, click Refresh Metafields on the Metafield Triggers page: the app remembers the list of definitions for an hour.

2. What the workflow receives

Every change starts the trigger Metafield Update in Shopify Flow with these values:

Variable Value
resourceType DRAFTORDER
resourceId The ID of the draft order, for example gid://shopify/DraftOrder/1234567890
metafieldKey Namespace and key, here custom.quote_status
metafield.value The new value
metafield.previousValue The value before the change, empty when the metafield was set for the first time
metafield.type The type of the metafield, for example single_line_text_field

3. Build the workflow

  1. In Shopify Flow, create a workflow and choose the trigger Metafield Update of Workflow Trigger Extensions.
  2. Add a Condition: resourceType is equal to DRAFTORDER. Metafield Update starts for every resource type you track, so the condition keeps this workflow to draft orders. When you track several metafields of the type, add metafieldKey is equal to custom.quote_status as a second criterion.
  3. Add the action you need. The example sends an internal email with the old and the new value.
The example workflow in Shopify Flow: Metafield Update, a condition on resource type DRAFTORDER and Send internal email
The example workflow: the trigger, the condition on the resource type and one action.

Start from the example

  1. Download the .flow file attached at the bottom of this page.
  2. In your Shopify admin open Flow, click Import and choose the file.
  3. Open the Send internal email step and enter the recipient. The file holds no address on purpose.
  4. Turn the workflow on.

Make it yours

  • Add a condition on metafield.value to react to approved only.
  • Tag the draft: add the action Add draft order tags and put {{resourceId}} in its draft order field.
  • Send the change to your CRM with Send HTTP request.

How fast it reacts

Shopify notifies the app when a draft order is saved, so the workflow usually starts within a few seconds.

More