Formatting issue when copying metafield from Company to Order

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:

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

1 Like

Hi @Polleke ,

Glad you got it working!