I’ve been testing and trying all sorts of combinations to access a generic file (a PDF) which is a metafield “file” value for a product.
This is for a flow that will give you the PDF URL of the file on a new order when products in lineItems have them.
I have been able to filter out the order line items, filter down into products, and only show those products that have the metafield reference key “pdf_reference”. But when trying to access the ACTUAL URL - I am unable to?
I can access the URL within the theme templates, and it’s present in user orders in their customer account pages - but when implementing the same idea to (eventually) send them a message/email with the PDF via Shopify Flows after an order has been placed - I cannot access the generic_file object?
The most I can get with metafield.value is e.g. “gid://shopify/GenericFile/1234567890987”. I have tried looping through the object, looping through the metafield options within “Flow”, and can get the values for namespace, key, value and type.
The documents for generic_file (https://shopify.dev/api/liquid/objects#generic_file)) do not appear to work within Flow? Or trying various Liquid filters and “hacks” such as “file_reference” or “file_url” only result in failed execution when the Flow triggers.
Can someone help me to the a product metafield URL value with a Flow?
Interesting. Flow recently added the new metafield types and what you are seeing is that what the file type stores is not a URL but a GID reference. That means you need a way to lookup the URL based on the reference (which is what the liquid does). This is not yet possible.
Thanks for getting back and confirming @paul_n - I had gone round in circles enough to worry that was the final answer! Do you know if there is a plan to add this into Flows? I feel Flows is no where near powerful enough yet to truly generate awesome triggers and actions.
It would be so much more transparent/streamlined and 1000% flexible if you could implement all Liquid code that you can in the theme files - i.e. being able to filter assigned variables, access file metadata (e.g. my issue), utilise objects like “all_products”. Being able to manipulate accessible Shopify Objects to output complex results would be so useful! Currently there is a gap that easily trips you up - as you can do something in the theme Liquid templates, but apply a similar method to filter/manipulate data in Flows, and it ends up not possible.
Most of the things you listed are already possible in Flow liquid. The context in which Flow is using liquid is different than the storefront so things like all_products wouldn’t just work in Flow. We do have plans to offering getting a list of products into Flow, but it’s addressed through a separate action called “Get product data”, which is in early access right now.
all_products wouldn’t just work in Flow. We do have plans to offering getting a list of products into Flow, but it’s addressed through a separate action called “Get product data”, which is in early access right now.
Thanks for the tip - i’ll see if I can utilise that action to pull out what I can for a product.
I did a bit more exploration on this. I think you can actually output the URL. For example, I updated an image to a “File” type and was able to access the URL for the image with this bit of code:
{% for metafields_item in product.metafields %}
{{metafields_item.reference.MediaImage.image.url}}
{% endfor %}
This gave me the CDN link to the file.
I’m not sure what makes a type a “GenericFile” but one possibility is that you have the type wrong. Like maybe it’s a single file type and not a list (which uses references vs reference).
I want to attach a pdf file in my draft order. I have added a metafield to attach pdf in products. Now I want to display that file url in my draft order email template. Can you please help me out here. The current code look like this:
{% for metafields_item in product.metafields %}
{{ line.metafields_item.reference.file.custom.estimate.url }}
{% endfor %}