Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi everyone!
I recently created a workflow that uses "Get customer data", checks a condition for certain tags and afterwards is ment to add lines to a spreadsheet, data of every customer in a new line.
For some off reason or from my own stupidity I cant get it to work properly and Flow adds all the data into one single row within the spreadsheet.
Here the row content I used:
{% for getCustomerData_item in getCustomerData %}
{{getCustomerData_item.firstName}},
{{getCustomerData_item.lastName}},
{{getCustomerData_item.email}},
{% for getCustomerData_item in getCustomerData %}
{% for tags_item in getCustomerData_item.tags %}
{{tags_item}},
{% endfor %}
{% endfor %}
{% endfor %}
Anyone has an idea what I am missing in the variables to have every customers data in a single line?
Help would be highly appreciated!
Armin
Update:
Now I got it to work at least in some way. The customers data is still not in one line for each customer. Instead now all the first names are in one cell, the last names in one cell, the mail adress and the tags. So it fills only 4 cells in all instead of x lines with 4 cell, each line for one customer.
Here the row content I am now using:
{% for getCustomerData_item in getCustomerData %}
{{getCustomerData_item.firstName}}
{% endfor %},
{% for getCustomerData_item in getCustomerData %}
{{getCustomerData_item.lastName}}
{% endfor %},
{% for getCustomerData_item in getCustomerData %}
{{getCustomerData_item.email}}
{% endfor %},
{% for getCustomerData_item in getCustomerData %}
{% for tags_item in getCustomerData_item.tags %}
{{tags_item}}
{% endfor %}
{% endfor %}
So basicly, although it changed, I am still searching for a way to skip to the next row after each customers data ...
Kindest regards!
Armin
You cannot add multiple rows in one Sheets action, unless you write a script in Sheets.
The solution is to use a For Each loop to repeatedly call "Add row".
After the condition you mentioned, use a "For Each" loop action. Inside that action you can call "Add row to Sheets".
Do not use your second attempt at the code...multiple loops over the same thing is almost never right.
Your code might look something like this:
{{getCustomerDataForeachitem.firstName}},
{{getCustomerDataForeachitem.lastName}},
{% for tags_item in getCustomerDataForeachitem.tags %}
{{tags_item}}-
{% endfor %}
Hey Paul,
Where exactly do I add the "For Each" loops? I cannot see where you have called an "add row to sheets" within the condition.
Could you help me with adding this "foreach" loop to my variables? I just want it to print out each order line item in separate rows like the standard "export orders" does...
{{order.name}},
{% for lineItems_item in order.lineItems %}
{{lineItems_item.quantity}},
{% endfor %},
{% for lineItems_item in order.lineItems %}
{{lineItems_item.name}}
{% endfor %},
{{order.customer.displayName}},
{{order.customer.numberOfOrders}},
{% for tags_item in order.tags %}
{{tags_item}}
{% endfor %},
@paul_n wrote:You cannot add multiple rows in one Sheets action, unless you write a script in Sheets.
The solution is to use a For Each loop to repeatedly call "Add row".
After the condition you mentioned, use a "For Each" loop action. Inside that action you can call "Add row to Sheets".
Do not use your second attempt at the code...multiple loops over the same thing is almost never right.
Your code might look something like this:
{{getCustomerDataForeachitem.firstName}},
{{getCustomerDataForeachitem.lastName}},
{% for tags_item in getCustomerDataForeachitem.tags %}
{{tags_item}}-
{% endfor %}
It will look like this roughly...
Hey Paul,
Thanks for the insight! I have added this to the flow but now it just prints the same data on 3 lines...
Could you explain how I get it to print each line item on its own line? Like the order export sheet does.
This is my code:
{{order.name}},
{% for lineItems_item in order.lineItems %}
{{lineItems_item.quantity}}
{% endfor %},
{% for lineItems_item in order.lineItems %}
{{lineItems_item.name}}
{% endfor %},
{{order.customer.displayName}},
{{order.customer.numberOfOrders}},
{% for tags_item in order.tags %}
{{tags_item}}
{% endfor %}
And this is my Flow:
You are using the wrong variable. You don't need to loop over lineitems in liquid because For Each is doing it for you. Click "Add a variable" and choose:
We have a template that shows this here:
https://shopify.com/admin/apps/flow/web/v2/editor/templates/e048b50b-63a9-4827-91fc-f9d0e08a49b8
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025