Customer Metafileds update from customer notes

Topic summary

A user needed to automatically transfer customer data (gender and birthday) from Shopify’s customer notes field into customer metafields using Shopify Flow.

Initial Problem:

  • The original Flow attempt failed because notes contained multiple lines of data, and the automation couldn’t parse multi-line text into a date field
  • When tested with only birthday data, it worked successfully

Solution Development:

  • Contributors provided Liquid code to parse multi-line notes by splitting on line breaks and extracting specific fields
  • Key technical adjustments included:
    • Using lines.first and lines.last instead of array index notation (not supported in Flow)
    • Changing customer.notes to customer.note (correct syntax)
    • Adding hyphens in Liquid tags ({%- and -%}) to remove unwanted whitespace/newline characters
    • Using lstrip filter to clean remaining whitespace

Final Working Code:
For gender: {%- assign lines = customer.note | newline_to_br | split: '<br />' -%}{%- assign gender = lines | first | split: ':' -%}{{- gender | last | lstrip -}}

For birthday: Similar structure using lines | last

The issue was resolved, with users confirming the solution works for extracting both fields from multi-line customer notes.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

Hello,

I have customer information, gender, and birthday, in the customer note section and I’d like to add the info into the customer metafield section automatically.
I tried to do this with Shopify flow but it doesn’t work at all.

How do I have to edit the flow?
Plz help!

Hi Dasoljong,

I noticed that your notes have multiple lines with different fields. Since notes is a text box, your automation will fail. The reason is that when you are trying to assign the result of getting the notes and removing ‘birthday’, the resulting output will be:

"gender:female

1992-07-08"

and this will not fit in a date shopify field. Can you try with just the birthday in the notes and see if it works that way?

Hello,

Just birthday, it worked.

However, I need gender and birthday.

Isn’t it possible?

You can try something like this on the value section:

{% assign lines = customer.notes | newline_to_br | split: ‘
’ %}
{% assign gender = lines[0] | split: ‘:’ %}
{{ gender[1] }}

for the other field

{% assign lines = customer.notes | newline_to_br | split: ‘
’ %}
{% assign birthday = lines[1] | split: ‘:’ %}
{{ birthday[1] }}

Remember to mark the solution and like it! :grinning_face:

1 Like

FYI, you cannot access list values with syntax like line[0] in Flow.

That said, in this case, you can iterate over that list using a loop or use the tag “first” or “last”.

Good point, Paul. I tried with plain liquid, not inside a workflow.

for the case DasolJol was proposing, and as Paul said, something like that should work:

{% assign lines = customer.notes | newline_to_br | split: ‘
’ %}
{% assign gender = lines.first | split: ‘:’ %}
{{ gender.last }}

for the other field

{% assign lines = customer.notes | newline_to_br | split: ‘
’ %}
{% assign birthday = lines.last| split: ‘:’ %}
{{ birthday.last }}

If you want to add more fields, then the logic will need to change.

Hello,

Thank you for your help!
However, I tried with the code above, it does not work.

It said, “notes” is invalid. So I changed it to “note”.

After that, it said “customer.note.last.last” is invalid. Replace this variable.

Could you help me with this error?

My fault Dasonjong,

In order to access the first and last element, you need to do this:

birthday | last

I’ve been trying the code and it works fine with the above-mentioned, except that for some reason, shopify adds some extra newlines characters. You will need a way to remove them in order to make this approach to work. for reference:

gender:

{% assign lines = customer.note | newline_to_br | split: ‘
’ %}
{% assign gender = lines | first | split: ‘:’ %}
{{ gender | last }}

birthday:

{% assign lines = customer.note | newline_to_br | split: ‘
’ %}
{% assign birthday = lines | last | split: ‘:’ %}
{{ birthday | last }}

Hope this helps.

The tags themselves add newline characters. You can remove them by using hyphens in that tags. For example, this will remove whitespace before and after the opening {% and closing %}

{%- assign lines = customer.note | newline_to_br | split: '
' -%}
1 Like

Thank you so much!
It works!

Hi, thank you for the solution but I have a problem, the result for 2 field he put the “\n” char

{
  "customer_id": "gid://shopify/Customer/9461841199368",
  "metafield": {
    "namespace": "custom",
    "key": "gender",
    "type": "multi_line_text_field"
  },
  "value": "\n\n Men\n"
}

and the result in the Metafield field is

how I can remove it?

ok resolved with paul_n solution plus a lstrip

{%- assign lines = customer.note | newline_to_br | split: '
'  -%}
{%- assign gender = lines | first | split: ':'  -%}
{{- gender | last | lstrip -}}