Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hoping someone can help with some error troubleshooting. Trying to setup a Flow that gets the value of a Product metafield (field is a single line text LIST metafield) and copies it to another Product custom metafield which is just single line text.
The Flow created is just returning a non-descript error "Error querying step configuration data. Try again in a few minutes". Retrying after a few minutes just returns same error.
The Flow will save and activate. But testing a change of Status in a Product the Flow doesn't update the field as expected.
So, not sure what might be wrong?
Trigger used is just 'Product status updated'.
The code used in the Value field:
{%- for metafields_item in product.metafields -%}
{%- if metafields_item.namespace == "custom" and metafields_item.key == "newlistfield" -%}
{{- metafields_item.value -}}
{%- endif -%}
{%- endfor -%}
Does the value from a single line text LIST metafield need to be transformed in some way to load to a single line text metafield?
Any help would be appreciated. Thanks in advance.
Solved! Go to the solution
This is an accepted solution.
Managed to solve my own question through some trial and error.
So, the 'Type' drop down list at the bottom needs to be set/changed to the Type of the field you are outputting to (destination), in this case 'Single Line Text'.
This got the Flow to work, but because the source field was a 'Single Line Text with a List of Values' (Multi-select Picklist) the output into the Destination field looked like this: ["Picklist Value 1","Picklist Value 2"]
So, I then had to parse/filter the values.
Depending on your use case, you may want to do one of two things, strip out the unwanted characters [ " ] and leave a comma and space between each picklist value. Or you may just want to just take the first picklist value. There are probably other use cases but I just looked at these two.
Shopify has some good Dev resources and info on Liquid String Filters here.
Anyway, Liquid code used in the Value field to copy just the first picklist value and strip out unneeded characters was:
{%- for metafields_item in product.metafields -%}
{%- if metafields_item.namespace == "custom" and metafields_item.key == "gexx" -%}
{{- metafields_item.value | replace: '["','' | remove_last: '"]' | split: '","' | first -}}
{%- endif -%}
{%- endfor -%}
The {{ - hyphens remove any white spaces.
| replace: '["','' removes the leading bracket and quotation mark and replaces with nothing.
| remove_last: '"]' removes the last quotation and bracket at the end of the string.
| split: '","' then splits the two values at "," and creates an array (basically a table of two values, or more if there is more).
and lastly, | first which returns the first value in the array.
Anyway, works for me.
Why did I want to do this?
Well, I am using Marketplace Connect to push Product to another sales channel. However, Marketplace Connect has a limitation. It won't directly map Single Line Text fields that have a List of Values (Multi-select picklist) - the app just won't show any multi-select fields in the Mapping drop down, it will only show Single Line Text Fields with a single value string. I needed a workaround. So, I created a custom Single Line Text field, used Flow to copy and filter/transform the value, and then mapped Marketplace Connect to this field.
Hope this may help someone else.
This is an accepted solution.
Managed to solve my own question through some trial and error.
So, the 'Type' drop down list at the bottom needs to be set/changed to the Type of the field you are outputting to (destination), in this case 'Single Line Text'.
This got the Flow to work, but because the source field was a 'Single Line Text with a List of Values' (Multi-select Picklist) the output into the Destination field looked like this: ["Picklist Value 1","Picklist Value 2"]
So, I then had to parse/filter the values.
Depending on your use case, you may want to do one of two things, strip out the unwanted characters [ " ] and leave a comma and space between each picklist value. Or you may just want to just take the first picklist value. There are probably other use cases but I just looked at these two.
Shopify has some good Dev resources and info on Liquid String Filters here.
Anyway, Liquid code used in the Value field to copy just the first picklist value and strip out unneeded characters was:
{%- for metafields_item in product.metafields -%}
{%- if metafields_item.namespace == "custom" and metafields_item.key == "gexx" -%}
{{- metafields_item.value | replace: '["','' | remove_last: '"]' | split: '","' | first -}}
{%- endif -%}
{%- endfor -%}
The {{ - hyphens remove any white spaces.
| replace: '["','' removes the leading bracket and quotation mark and replaces with nothing.
| remove_last: '"]' removes the last quotation and bracket at the end of the string.
| split: '","' then splits the two values at "," and creates an array (basically a table of two values, or more if there is more).
and lastly, | first which returns the first value in the array.
Anyway, works for me.
Why did I want to do this?
Well, I am using Marketplace Connect to push Product to another sales channel. However, Marketplace Connect has a limitation. It won't directly map Single Line Text fields that have a List of Values (Multi-select picklist) - the app just won't show any multi-select fields in the Mapping drop down, it will only show Single Line Text Fields with a single value string. I needed a workaround. So, I created a custom Single Line Text field, used Flow to copy and filter/transform the value, and then mapped Marketplace Connect to this field.
Hope this may help someone else.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024