Can you help me send multi lines text field into a meta field via API, and show me the code piece to be used, please.
Sincerely, Jesper
Can you help me send multi lines text field into a meta field via API, and show me the code piece to be used, please.
Sincerely, Jesper
Hi @JLVJ
multi lines text fields accept standard text with regex new lines character (for example “\n” or “\r” or, more usually “\r\n”.
So, suppose you’re creating a product with a metafield which type is multi_lines
{
“input”: {
“title”: “New Cool Product”,
“metafields”: [
{
“namespace”:“XYZ”,
“key”:“key_name”,
“type”: “multi_line_text_field”,
“value”: “test\r\nvalue with new lines”
}
]
}
}
Hi Francesco
Thank you, I will forward this to the developer and see if it works.
Jesper
Hi Francesco
It did not work for us, but your input was correct. It seems what we are looking for is Multi_line as a list. Do you by any chance know that as well?
Best regard, Jesper
hi @JLVJ
the “list” is just a display concept, if you can explain what are you trying to achieve and where (are you trying to access metafields with Liquid on frontend for example?) I can give you more precise suggestions!
Yes of course, we trying to send data from ERP to Shopify with api.
I have attached 2 image
with multi_lines, but not in a list
Multi_lines in a list (made manually in Shopify)
it is number 2, we are trying make
hi @JLVJ
totally clear!
you have to configure the metafield you want to use as “list” as
Single Line Text Field → List of values instead of single value
then you just have to edit the api call, passing the list of values as an escaped array of values so, given the values as :
["value_1", "value_2"]
you will edit the mutation input this way
{
"input": {
"title": "New Cool Product",
"metafields": [
{
"namespace":"XYZ",
"key":"key_name",
"type": "single_line_text_field",
"value": "[\"value_1\", \"value_2\"]"
}
]
}
}
please note that if you want to update the field (so without losing the actual values) you will firstly need to call the product and parse the metafield and then compose the input for the update with metafield value = old values + new values
as the update mutation will overwrite the data!
Hello,
I have the impression that the answer is not totally correct.
The answer allows you to fill in a single line list field. But not multiline text.
How can you fill a multiline text field?
Thank you in advance for your help
hi @Get_Quark !
Actually the premise of the question was “wrong” as we both confused the metafield type “multi_line_text_field” with the “list.product_reference” type.
for the multi_line_text_field my first answer is still right:
{
"input": {
"title": "New Cool Product",
"metafields": [
{
"namespace":"XYZ",
"key":"key_name",
"type": "multi_line_text_field",
"value": "test\r\nvalue with new lines"
}
]
}
}