How can I update metafields using if condition in a product's stock analysis?

Topic summary

A user is attempting to extract specific XML values from a product metafield (product.stockanalysis) and populate them into separate metafields (product.localstock and product.supplierstock).

Technical Challenge:

  • The source metafield contains XML data with values like <LocalStock>0</LocalStock> and <Quantity>1</Quantity>
  • The user tried using Liquid templating with string parsing (split operations) in Shopify Flow to extract these values
  • The conditional logic approach is not functioning as expected

Solution Provided:
A respondent notes that Shopify Flow now supports direct metafield access through the UI:

  • Navigate to product → metafield in Flow
  • Select the desired metafield from a dropdown list
  • The system automatically inserts it into the workflow

This suggests the manual XML parsing approach may be unnecessary with Flow’s native metafield handling capabilities. The discussion remains open regarding whether this resolves the specific extraction requirement.

Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Hi

I am trying to update the meta field from one metafeild to another one

I have one metafeild with below value

Namespace and key product.stockanalysis

100342105 -999 0 0 1 true SupplierOther false 1 -999 false

Result metafeild name and key

product.localstock

product.suppilerstock

Now I want 0 and 1 to show on sperate metafeild is it possible

I am using this condition on flow but not working properly

{% metafields.product.stockanalysis %}
{% assign metafield_content = metafields.product.stockanalysis %}
{% if metafield_content contains ‘’ and metafield_content contains ‘’ %}
{% assign start = metafield_content | split: ‘’ | last %}
{% assign end = start | split: ‘’ | first %}
{{ end }}
{% else %}
“Metafield does not contain the desired text”
{% endif %}

I know this is very late, but you can now access metafields in Flow using by choosing product / metafield and then choosing the metafield from a list. It will then insert that metafield into the workflow.