How to correctly update a variant metafield using flow?

Hi experts,

Sorry, it is partly in dutch! let me know if you need anything to be translated.

I created a flow that updates a variant metafield to the variant when it is created.

Now everything runs fine. Only thing is.

When the metafield is updated (created) it will not be the one I want to be updated. It will show as a Non structured metafield

While I want it to be the following metafield: (in the added picture I updated the metafield manually)

Now this might be because the variant metafield I created has pre made answers. I added the page below:

I also added a screenshot of the flow:

Please let me know what to try?

Kind regards,
Pim

The metafield namespace and key you’re using in Flow do not match the metafield definition you created.

Your metafield definition has namespace of Variant_field and key of maten_van_varianten.

Your workflow is using namespace Maat (which is the name of the metafield, not the namespace), and key of Variant_field.maten_van_varianten (which is actually the namespace and key combined).

You’ll need to update your workflow to use the namespace and key as defined in the metafield definition.

Hi Jeff,
Thank you so much for taking the time to help.

Your answer makes sense. I changed it and now get the following error:

8 feb 2024 om 18:46

Got error updating metafield: “Value is invalid JSON: unexpected token at ‘Prematuur’.” For value: “Prematuur”, Type: list.single_line_text_field

Do you have any idea what I need to do?

I tried looking for “list.single_line_text_field” as the option:

In your metafield definition, you defined it as a single line of text, one word.
You’d need to select Single line text as the type in Flow to match that.

Hi jeff,

Thanks again for the reply.

I had it in single line text (after I changed the namesapce and key). I still got an error:

Can you please let me know If I need to adjust something here:

It looks like you have Lijst met waarden selected on the metafield definition, so this will expect a list of single line strings.
You’ll need to create a new metafield definition if you only want a single value to be stored per key.
If you want multiple values to be stored for a single metafield key, then you’ll need to select list of single line strings as the type in Flow. Since the value is now a list of values type, your value field in Flow also needs to be a list, not just a single string.

Hi Jeff,

Thanks again.

The problem is, I tried this already and that will result in the following:

The problem is: there is not “list.single_line_text_field” option…

I guess it is just not possible…?

There is an option … in English it is called “List of Single Line Strings” as shown in your screenshot above.

When you update that value, the list must look like [“item1”, “item2”]

Hi Paul,

Thanks a lot! The input value was the problem! Changed it to: [“item1”, “item2”] and now it works.