Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
When trying to update an Order metafield with the value copied from a Company metafield, I get the error: Got error updating metafield:
Value does not exist in provided choices: ["AAA", "BBB", "CCC"]." For value: "["BBB"]", Type: single_line_text_field
The value "BBB" is the correct output for this order, but it seems that Flow adds "[ ... ]", and next it's rejected for not matching my provided choices. How do I get rid of the "[ ... ]" eclosure?
Here is the liquid used in the value box
{%- for companyContactProfiles_item in order.customer.companyContactProfiles -%}
{%- for metafields_item in companyContactProfiles_item.company.metafields -%}
{%- if metafields_item.namespace == "custom" and metafields_item.key == "partner" -%}
{{ metafields_item.value }}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
Screenshot of that code:
Solved! Go to the solution
This is an accepted solution.
Hi @Polleke,
Flow doesn't try to add any square brackets as part of that action so it is likely related to the input data. What type is the custom.partner metafield on the company? If it's a list of single line text values, that would explain why it is showing up like an array.
If the input metafield is a list of single line text values and the output metafield is a single line text value, you'll need to use Liquid filters to transform the data from a stringified array into something that can be used in the single line text field. Because the source field looks like it's a list, there could be more than one value in the metafield. That is something you'd likely have to consider.
Hope that helps!
This is an accepted solution.
Hi @Polleke,
Flow doesn't try to add any square brackets as part of that action so it is likely related to the input data. What type is the custom.partner metafield on the company? If it's a list of single line text values, that would explain why it is showing up like an array.
If the input metafield is a list of single line text values and the output metafield is a single line text value, you'll need to use Liquid filters to transform the data from a stringified array into something that can be used in the single line text field. Because the source field looks like it's a list, there could be more than one value in the metafield. That is something you'd likely have to consider.
Hope that helps!
Hi Dave,
Thanks for pointing me in the right direction!
By mistake the partner metafield in Companies had been set up at single line text, multiple values.
The Order metafield partner was set up correctly as single line text, single value. Both use a validation list.
After we corrected the mistake with the Companies metafield, both metafields were configured exactly similar, and now Flow copies the partner value as intended to the order
Hi @Polleke,
Glad you got it working!
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024