I am trying to run a task in Flow to unpublish a product when a draftOrder is created, due to lineitems being custom, we cannot use the standard productId on the line item to unpublish the product so I am thinking if can store productId and somehow can use it to unpublish the product?
Below is my Liquid code in “Select product” section, which outputs the ProductId correctly but we still get “Exception: Invalid Shopify Global ID: gid://shopify/Product/9867160289561” error when the Flow runs, any idea what is the correct syntax for returning productId from “Select product” section?
{% for customAttributes_item in lineItemsForeachitem.customAttributes %} {% if customAttributes_item.key == “productId” %} gid://shopify/Product/{{customAttributes_item.value}} {% break %} {% endif %}
{% endfor %}
It’s hard to tell exactly where you entered this (maybe you are overriding the resource for an action?), but it’s possible that you have whitespace around the ID, or that you’ve entered a variant ID and not a product ID.
To remove whitespace before and after a liquid tag, you can use hyphens like {%- and -%)