We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Updating Link metafield with flow

Solved

Updating Link metafield with flow

Camrog
Tourist
5 0 0

Hey there - I am trying to use flow to set the value for a metafield with the type Link. My understanding is that there are two portions of the Link metafield... the text that is displayed and the URL.

 

I created a flow that sets custom.metafieldname.value.text and custom.metafieldname.value.URL ... and the flow says it runs ... but the metafield doesn't seem to actually update. 

 

I am likely doing something horribly wrong ... so any help is appreciated. 

Thanks!

Accepted Solution (1)

paul_n
Shopify Staff
1828 199 435

This is an accepted solution.

That is not how you set them. A namespace and key will not include any ".". In the above, your namespace is custom and the key is metafield name. The value field for a link type metafield can be found in the docs. https://shopify.dev/docs/apps/build/custom-data/metafields/list-of-data-types

 

For a link it looks like:

{ 
 "text": "Learn more", 
 "url": "https://shopify.com"
} 
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.

View solution in original post

Replies 6 (6)

paul_n
Shopify Staff
1828 199 435

This is an accepted solution.

That is not how you set them. A namespace and key will not include any ".". In the above, your namespace is custom and the key is metafield name. The value field for a link type metafield can be found in the docs. https://shopify.dev/docs/apps/build/custom-data/metafields/list-of-data-types

 

For a link it looks like:

{ 
 "text": "Learn more", 
 "url": "https://shopify.com"
} 
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.
Camrog
Tourist
5 0 0

Thanks! That helped me figure it out. 

xyz2157
Excursionist
13 0 0

Hey Paul,

 

Follow up about a metafield that's a list of links. I've checked the documentation and made sure my formatting matches, except for the line breaks. My Flow automation to update the metafield list of links keeps triggering an error, however. Does Flow not support the List of Links? I have "List of URLs" selected, and don't see the option "List of Links."

 

ri2_0-1737130473288.png

 

Here are all the "List of" options: 

ri2_1-1737130499415.png

 

I am getting this error (bolded the parts that are not the value/contents):

Exception: Got error updating metafield: "Type 'list.url' must be consistent with the definition's type: 'list.link'." For value: "[{ "text": "", "url": "https://admin.shopify.com/store/xxx/checkouts/35313837703396"},{ "text": "", "url": "https://admin.shopify.com/store/xxx/checkouts/35313724457188"},{ "text": "", "url": "https://admin.shopify.com/store/xxx/checkouts/35313837703396"}]", Type: list.url

 

 

paul_n
Shopify Staff
1828 199 435

Looks like your text fields are all blank. But a list of URLs is not the same as a list of links. So you need to select "list of links" and make sure you provide them with a title. But I don't think Flow currently has that metafield type available.

 

If possible you could change your metafield type to be a list of URLs. And then provide those URLs according to this doc: https://shopify.dev/docs/apps/build/custom-data/metafields/list-of-data-types

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.
xyz2157
Excursionist
13 0 0

Hey Paul, the first 2 links in the list, I added manually and they didn't require the text field. So it doesn't seem like the text field is required, so I don't think that is the problem.

 

I'm concluding the option "list of links" is just not currently supported, as you suggest.

 
Solutino: I changed the metafield type to "list of URLs" (deleted metafield definition and re-added a new definition), and updated the Flow code to match the formatting for "list of URLs", and now it works.
paul_n
Shopify Staff
1828 199 435

List of links is a new metafield type. Flow will support it relatively soon. 

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.