# Material metafield tracking

Define custom fields on materials, optionally link them to Shopify, and capture per-batch values inside work orders.

import Term from '~/components/Term.astro';
import { Aside, Steps, LinkCard } from '@astrojs/starlight/components';
import DocUpdated from '~/components/DocUpdated.astro';

Assemblified lets you attach custom fields — lot numbers, expiry dates, supplier IDs, calibration dates, inspection flags — to <Term def="raw-material">materials</Term>, then capture per-production-batch values inside <Term def="work-order">work orders</Term>. The system has three layers: a definition you create once, a default value you set on each material, and a per-batch value entered when a work order is built. Linking a definition to Shopify is optional.

## On this page

- What a material metafield is
- Create a metafield definition
- Connect a definition to Shopify (optional)
- Set a default value on a material
- Track per-production-batch values in work orders
- Common use cases

## What a material metafield is

A <Term def="metafield">metafield</Term> is a custom key-value field that travels with a material. The same definition is reused everywhere a material is referenced, so once you've defined "Lot Number" you can capture it on any material on any work order.

The data flows in three layers:

| Layer | Where you edit it | What it captures |
|---|---|---|
| 1. Definition | Settings → Metafields | The name, type, and optional Shopify link. Reusable across every material. |
| 2. Per-material default | Material detail → **Metafields** tab | A current value on the material itself. Optionally pulled from Shopify. |
| 3. Per-batch value | Work order → **Documents & Build Metafields** tab | The value for *this* production run, either across all units or per-unit. |

Definitions support four types — `text`, `number`, `date`, `boolean` — and the input on every layer adapts to match.

## Create a metafield definition

Definitions live on the **Metafields** page under **Settings → Catalogues**. The same list is what every material's Metafields tab offers, so add anything you'll want to capture before you start filling in values.

<Aside type="caution">
Creating, editing and deleting metafield definitions requires the **Enhanced** plan — the page says so and offers **Upgrade**. Existing definitions stay readable and their values stay editable; only the definitions themselves are gated.
</Aside>

<Steps>

1. **Open Settings → Metafields.** The page lists every definition the store has, with its type and its Shopify connection.

2. **Click Add Metafield.** The **Add Metafield Definition** dialog opens.

3. **Name the field.** Keep it operator-friendly — "Lot Number", "Supplier", "Expiry Date". The name is what shows up on materials and work orders.

4. **Pick a type.** Text, Number, Date, or True/False. Type is permanent — you can't switch a definition from text to date later without deleting and re-creating.

5. **(Optional) Add a description.** Shows up as helper text on the input.

6. **(Optional) Link to Shopify.** Toggle on if you want this definition to mirror a Shopify metafield — see the next section.

7. **Save.** The definition is immediately available on every material's metafields tab.

</Steps>

Editing a definition only changes its name, description, and Shopify link. Existing values keep their snapshots (see [Track per-production-batch values](#track-per-production-batch-values-in-work-orders)). Deleting a definition cascades and removes every recorded value across materials and work orders.

## Connect a definition to Shopify (optional)

When you toggle **Link to Shopify Metafield** on, you pick:

- **Owner type** — Product or Product Variant. Determines which Shopify metafield namespace + key the link maps to.
- **Shopify metafield** — a dropdown populated from the Shopify Admin API listing the existing metafield definitions for that owner type.

Once linked, Assemblified can pull the current Shopify value into the per-material default. The pull is **one-way** — values flow *from* Shopify *into* Assemblified, not the other way around. The link gives you:

- A **prefilled value** when you assign the definition to a material (the current Shopify value populates the input).
- A **Sync from Shopify** button on the material's **Metafields** tab to refresh values later.
- An **Overridden** badge if you change the local value so it no longer matches Shopify, with **Reset to Shopify value** in the row's menu to pull it back in.

<Aside type="note">
If you only want a value local to Assemblified — never reflected in Shopify — leave the toggle off. Linked or not, the definition behaves the same on work orders.
</Aside>

<span id="set-a-default-value-on-a-raw-material"></span>

## Set a default value on a material

Once a definition exists, you assign it to specific materials and give it a starting value.

<Steps>

1. **Open the material detail page.** Materials → pick a material.

2. **Switch to the Metafields tab.** The **Metafield values** card lists every metafield already assigned to this material, with its value, a source badge (Manual or Shopify), an optional note and its change history.

3. **Click Add value.** A picker opens — only definitions that aren't already assigned to this material show up.

4. **Pick a definition and enter a value.** If the definition is Shopify-linked, the current Shopify value prefills the input. Override it if needed.

5. **(Optional) Add a note.** Free-text — useful for "received 2026-01-15" or "verified by ops".

6. **Save.** The value is now the default for this material everywhere it gets used.

</Steps>

If any values on the page are Shopify-linked, a **Sync from Shopify** button appears in the card header. Clicking it refreshes the recorded Shopify value and the `lastSyncedAt` timestamp without overwriting your local override — the Override badge stays on so you can see the divergence and decide whether to reset.

Every change — create, update, reset, sync — is recorded, and **Change history** on the row shows it. Use it to audit who changed a supplier ID and when.

## Track per-production-batch values in work orders

The headline use case. When a work order is created, every assigned material brings its definitions along. Each production batch can record its own values without affecting other work orders or the material's default.

Open a work order and switch to the **Documents & Build Metafields** tab. The **Build metafields** card lists each material with its assigned definitions, grouped **By material** or **By metafield** as you prefer, and offers two tiers per definition:

- **One value.** A single value applies to every produced unit. Use this when "this whole batch came from supplier X" or "every unit shares the same lot number".
- **Per unit.** Distinct values per unit (1, 2, 3, … up to the run quantity). Use this when batches arrived at different times — units 1–5 expire June, units 6–10 expire August — or when each finished good carries a unique serial number.

When a material is added to a work order, Assemblified copies the material's current default into the work order and badges the row **Prefilled**, so operators don't re-type values that already exist. Prefill only runs once per material — editing the material's default later does *not* retroactively update active work orders. The row's menu carries **Update the material's default** for the other direction.

A work order records the definition's **name and type as they were** when the value was entered. Renaming "Lot Number" to "Batch ID" later won't rewrite history on already-completed work orders — they keep showing whatever the field was called when the value was captured.

<Aside type="caution">
Switching a definition's tier on a material **clears every existing value for that definition on that material**, and the app asks before it does it — *Switch to one value?* warns that everything that definition holds on that material is cleared first. Choose the tier before you start entering values, not after.
</Aside>

If your store writes Assemblified's material requirements into Shopify order metafields (**Settings → Integrations → Shopify order metafields**), completing a work order refreshes that payload for every order the work order was created from, laying what you recorded here over the values derived from the bill. Picker and shipper workflows that read the order metafield then see what actually went into the build.

Three things bound what reaches Shopify:

- Only **one value** entries travel. Per-unit values stay inside Assemblified.
- Only definitions named **Notes**, **Specifications** or **Lot number** are mapped into the order payload, because those are the three fields the payload has. Other definitions are recorded and reportable in Assemblified but are not written to the order.
- Only values on **materials** are carried.

If the order-metafield setting is off, nothing is written to Shopify at all. See [Shopify extensions](/integrations/shopify-extensions/) for the payload itself.

## Common use cases

- **Lot / batch number** (text). Often per-unit when each finished good carries its own lot, or material-level when one batch supplies a whole work order.
- **Expiry date** (date). Usually per-unit, since one delivery can mix batches with different shelf lives.
- **Supplier ID** (text, often Shopify-linked). Material-level — the supplier doesn't change unit by unit, and a Shopify link keeps it in sync with your product catalogue.
- **Pre-inspected flag** (boolean). Material-level on incoming inspection — flips to true once a QC pass logs the batch as cleared.
- **Calibration date** (date). For tooling or measurement-sensitive materials — captured at receipt and audited later.

## Where to next

<LinkCard
  title="Work orders overview"
  href="/features/work-orders/overview/"
  description="The work-order detail page the Documents & Build Metafields tab lives on, and what the other four tabs carry."
/>

<LinkCard
  title="Shopify sync"
  href="/features/work-orders/shopify-sync/"
  description="What a completing work order writes back to Shopify, and when."
/>

<LinkCard
  title="Reporting (PDFs)"
  href="/features/work-orders/reporting/"
  description="Pick lists and PDF templates can include per-row metafield columns so operators see lot/expiry on the floor."
/>

<LinkCard
  title="Materials overview"
  href="/features/raw-materials/overview/"
  description="The home page for materials, where definitions get applied and Shopify-linked values get synced."
/>

<DocUpdated date="2026-10-19" />