Flow Automation: Retrieving Metafields via Action
You can use the Query metafields action in Flow Automation to retrieve custom data stored in your store's metafields. This allows you to use these custom attributes as Conditions or Variables in your workflows, enabling advanced automation scenarios such as sending digital product links or categorizing orders based on custom attributes without writing any code.
This guide explains the supported resources, field descriptions, and practical examples for using metafields in your workflows.
| Note: This feature is only applicable to resources (Products, Variants, Collections, Orders, or Customers) that have already been configured with metafields. For more information on how to set up metafields, please refer to "Customizing Your Store Content with Metafields." |
Supported Resources
The Query metafields action supports retrieving data from the following five core resources:
- Product metafields
- Product variant metafields
- Customer metafields
- Order metafields
- Collection metafields
Supported Data Types
- Single-line/Multi-line text
- Date
- Integer
- Boolean
- URL
-
File
Note: Flow Automation automatically converts "File" types into accessible URLs for use in email variables.
Field Descriptions
When configuring the Query metafields action, define the following fields:
| Field | Description |
| Namespace | The category name used to group related metafields. |
| Key | The specific name of the metafield to be retrieved. |
| Source Resource | Select the object (e.g., Variant or Customer) where the metafield is stored. |
|
Note: When configuring the Query metafields action, once you select the Source resource (e.g., Product or Variant) and enter the corresponding Namespace, Flow Automation will automatically retrieve and display the available Key values predefined in your store's Metafield settings (Settings > Customize data). This ensures data consistency and simplifies the selection process. For more information on how to set up metafields, please refer to "Customizing Your Store Content with Metafields." |
Usage Limits and Notes
- Internal Operations Only: This action cannot be used to display data on your storefront or interact with the Theme Editor.
- Workflow Constraints: Each workflow can only contain one Query metafields action, and it cannot be placed after a For each loop.
- Deleted Metafields: If a metafield used in a Flow is deleted, a red exclamation mark warning will appear, and saving the workflow will be blocked.
- Email Security Review: Workflows involving Send email notification will undergo a risk control review. If anomalies are detected, the workflow will be deactivated.
Example Use Case
Here are two practical examples of using the Query metafields action to automate advanced internal operations.
Use Case 1: Automatically Send Digital File Links Upon Order Creation
Scenario: Send download links (single or multiple files) stored in SKU metafields to customers after a successful purchase.
- Trigger: Order created
-
Action: Query metafields
- Source: Product variant metafields
-
Type: File - single or multiple values
Note: When selecting a metafield, ensure that you associate it with the correct variable. For example, query a Product metafield using the 'Product ID,' an Order metafield using the 'Order ID,' and so on.
- Condition: Check if the corresponding metafield value is not empty.
-
Action: Send email notification
- Subject: Order Success - File(s) for: ${trigger.line_item.name}
-
Email Content: Insert the variables ${metafield.variants.digital_multi_file.key} or ${metafield.variants.digital_file.key}.
Note: To insert variables, click Add variables and select the appropriate parameters from the list. - Recipient: Manually enter the email addresses of the staff members who should receive the notification.
- Outcome: When a customer purchases a digital product, the system automatically retrieves the unique download link(s) from the SKU's metafield and sends them directly to the customer, ensuring immediate fulfillment without manual intervention.
Use Case 2: Categorize Orders Based on SKU Metafield Values
Scenario: Automatically add tags to an order based on the custom text values stored in the SKU's metafield.
- Trigger: Order created
-
Action: Query metafields
- Source: Product variant metafields
- Type: Single-line text - multiple values
- Condition: Check if the product variant's metafield value is not empty.
-
Recipient: Add order tags
- Order ID: ${trigger.id}
- Tags: ${metafield.variants.my_fields_sku_multivalue.key}
- Outcome: This workflow automatically labels orders based on custom product attributes, allowing the operations team to quickly filter and manage orders in the admin panel according to specific SKU-level data.