Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi. I'm trying to get a customer metafield (type: list of dates and times) to update when that customer purchases a particular product. (Specifically this is an annual membership product and I want to record a list of dates for when the customer purchases/renews it.)
The Flow trigger (order created) and condition (if SKU equals) are working correctly. However the action to 'update customer metafield' is always returning an error.
I have the value in Flow as {{order.createdAt | date: "%Y-%m-%d"}} but it's giving me the error "Got error updating metafield: "Value is invalid JSON: unexpected token at '-10-10'." For value: "2024-10-10", Type: list.date_time."
Do you know what I should have the value you in order for this to work? Thanks.
Hi @DaveHewer,
Could it be that you're trying to add a single date to a list type? That requires a specific syntax.
I found a similar question with a solution at https://community.shopify.com/c/shopify-apps/how-can-i-add-to-a-list-of-datetimes-in-flows/m-p/24746....
Yeah I think that's it.
Thanks for the input @Webstablish.
I've tried putting the value in square brackets and adding quotation marks (see below). However, the post you linked to seemed to be assuming that I wanted to add a list of dates, whereas I'm wanting to add a single date to a list of dates.
["{{order.createdAt | date: "%Y-%m-%d"}}"]
You should see it as an array, so even if it can contain multiple values you can give it a single item initially. The comma separates multiple items. So on the next renewal you have to somehow model: [currentValue + ',' + newValue].
Thanks — that makes sense. Can you give me any more pointers on how exactly to achieve that?
Hi Dave,
Two things here:
1. The date format should be date:
"%Y-%m-%dT%H:%M:%S"
2. You can use the following liquid in the "value" part of the "Update customer metafield" step:
[
{% for value_item in customer.thedates.value %}
"{{value_item}}",
{% endfor %}
"{{customer.createdAt | date: "%Y-%m-%dT%H:%M:%S"}}"
]
I'm using customer instead of order in this example and I've created a metafield alias (as described here) called "thedates". This liquid gets all of the existing values of the metafield and then adds another value. Note that this could run into issues with multiple workflows or apps updating this specific metafield if they use the same namespace and key.
Thanks!
Ryan
I think I'm close to getting this to finally work, but it's not quite there yet. I'm no longer getting an error on the Flow logs (it's saying the metafield is being successfully updated) but nothing has actually been added to the customer's metafield when I check it.
Screenshot below of the Flow action dialogue box, with the value as follows:
[
{% for value_item in order.customer.championOrderDates.value %}
"{{value_item}}",
{% endfor %}
"{{order.createdAt | date: "%Y-%m-%dT%H:%M:%S"}}"
]
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025