automated metafields

automated metafields

Michael42
Tourist
17 0 1

Hello, I want to automate the Katecorgi metafields by writing a product description, and then I want the system to extract the values for the metafields from the description. I keep geting errors.

Skärmavbild 2025-04-23 kl. 15.40.49.png

Replies 21 (21)

paul_n
Shopify Staff
1764 193 410

It's not clear what you want to do here and why you've left the value field empty when updating a metafield. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

I want to write a product description. For example:

Technical details
Glass: Mineral glass

When the system detects the value 'Mineral glass' in the description, I want it to automatically extract that value and place it in the metafield for 'type of glass'.

paul_n
Shopify Staff
1764 193 410

If it's in the description, you need to do string parsing on the description. It really depends on how consistent your descriptions are, but probably I would use Run code on that as JavaScript has more tools for string parsing then Liquid.  But Liquid might work as well. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

Michael42
Tourist
17 0 1
Could you still help me? this is the errors. I also dont know what to put
in the value. i have already created a metafield and the values for that
metafield[image: Skärmavbild 2025-04-24 kl. 23.13.36.png]
[image: Skärmavbild 2025-04-24 kl. 23.13.58.png]
paul_n
Shopify Staff
1764 193 410

no image came through your post.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

Skärmavbild 2025-04-25 kl. 15.41.04.png

paul_n
Shopify Staff
1764 193 410

Your metafield is a metaobject reference. You cannot change the values in a metaobject by updating the product metafield. Instead you would need to update the metaobject. 

 

To do that, you would use "Send Admin API request" with the "metaobjectUpdate" mutation. You'll need to set the JSON in that update. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

thanks for the help but i still get some errors. I tried with the metaobjectupdate and got this errors  "Mutation had errors: "Variable $id of type ID! was provided invalid value", "Variable $metaobject of type MetaobjectUpdateInput! was provided invalid value"                                       {
"query": "mutation metaobjectUpdate($input: MetaobjectUpdateInput!) { metaobjectUpdate(input: $input) { metaobject { id } userErrors { field message } } }",
"variables": {
"input": {
"id": "gid://shopify/Metaobject/170755064149",
"handle": "kristallglas",
"fields": [
{
"key": "typ",
"value": "Kristallglas"
}
],
"capabilities": {
"publishable": {
"status": "ACTIVE"
},
"onlineStore": {
"templateSuffix": ""
}
},
"redirectNewHandle": false
}
}
}

paul_n
Shopify Staff
1764 193 410

It appears you are including fields that you really don't need to update so it's not clear which field this error is complaining about. Assuming that it's they value field for your metaobject, you need to share more details about your metafield, specifically the types of each field. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

Skärmavbild 2025-04-27 kl. 19.36.13.png

Skärmavbild 2025-04-27 kl. 19.36.50.png

Skärmavbild 2025-04-27 kl. 19.37.21.png

Michael42
Tourist
17 0 1

Skärmavbild 2025-04-27 kl. 19.39.27.png

Michael42
Tourist
17 0 1

hello could you find the problem?

 

paul_n
Shopify Staff
1764 193 410

Your key for that field is either "glas" or "glas.glas" not "typ"

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

Skärmavbild 2025-04-29 kl. 01.52.05.png

As you can see in the SC everything works and i get no errors anymore but value in the metafield does not fills. the code: {
"id": "gid://shopify/Metaobject/170755064149",
"metaobject": {
"handle": "kristallglas",
"fields": [
{
"key": "glas",
"value": "kristallglas"
}
],
"capabilities": {
"publishable": {
"status": "ACTIVE"
}
},
"redirectNewHandle": false
}
}

paul_n
Shopify Staff
1764 193 410

You aren't updating a product metafield but a metaobject. If you go to "Content" in the Admin you should see what you updated.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

So should i set a metafieldsSet mutation or please what should i do? Im useing a categori metafilds for my products 

paul_n
Shopify Staff
1764 193 410

I don't know because it's unclear why you are using a metaobject at all if you just want a description. If that's all you need, then create a product metafield that is multi-line text and use the "Update product metafield" action on it. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

Skärmavbild 2025-04-29 kl. 16.23.02.png

Skärmavbild 2025-04-29 kl. 16.23.16.pngI still get error

paul_n
Shopify Staff
1764 193 410

That error means you had a new line

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Michael42
Tourist
17 0 1

i think i got it thanks 

Michael42
Tourist
17 0 1

Skärmavbild 2025-04-29 kl. 16.41.22.png

Using a multi-line text field won't work for me, because I'm using this metafield for filtering products in my store. I've already manually filled in data for over 400 products, so I can't simply switch the metafield type to multi-line text without losing that work. I need to find a sulation for my metaobjets