I’m using Flow to insert return data into Google Sheets. When there is more than one item returned it is putting all of the data in a single row. How can I break up the data into new rows? I have tried many different characters and can’t find anything that’ll work.
Thank you for your response. I really am not familiar with Google Sheets, so will need to figure out what the ## is supposed to do and how. Below is what I see when I click on your link. I don’t see new rows splitting at the ##.
Oops, see it now. I inserted ## at the end of my flow statement, and added your code into google sheets. but it is only splitting within the one cell. I need it to start a whole new row with all the data after the ##.
I might need to see the code…but note that the column with the lineItems should be a single column and use :: to separate fields (because the comma will be split by Sheets and mess things up). Also note the heading uses the same approach to generate column titles
For example, the code for row2 would look like (ignoring liquid for now):
1234, Product A::1::sku_0#product B::3::sku_2, John Doe
Look again at my code…not all commas are replaced. Just those for the line items. Also, you putting all of the order details inside the loop, causing them to repeat. Try something like this:
Hi Paul, I am trying to recreate the sample you have given by duplicating the same example data + code, but it returns to this error.
TypeError: Cannot read properties of undefined (reading ‘length’)
result [email removed] Untitled.gs:14
also, what do you mean by this approach should no longer be necessary if I use the “For Each” loop? is there an alternative way to achieve this without using appscript?
This is my row content on shopify flow:
{{draftOrder.id}}, {{draftOrder.totalPrice}}, {{draftOrder.currencyCode}}, {% for lineItems_item in draftOrder.lineItems %} {{lineItems_item.name}}:: {{lineItems_item.id}}:: {{lineItems_item.quantity}}## {% endfor %}
You can use the For Each action now to iterate through the line items on the refund and add rows to the spreadsheet one at a time. Here’s a quick example of how that could work:
I am trying to pass over line items to a spreadsheet and each line item needs to fall into the next row. Using ‘for each’ passes over all the all order info for the applicable number of variants into that number of rows. Is there a way to pull all info into the next row but not all line items, just the next line item? Does that make sense? Copy of my row contents below and screenshot of flow + outcome.
Im trying to do something simular, but to separate each item ordered into a separate row.
How can I go about doing that?
Below is my current row contents
{{order.name}}, {{order.shippingAddress.name}}, {{order.shippingAddress.address1}}, {{order.shippingAddress.address2}}, {{order.shippingAddress.company}}, {{order.shippingAddress.city}}, {{order.shippingAddress.zip}}, {{order.shippingAddress.province}}, {{order.shippingAddress.country}}, {% for lineItems_item in order.lineItems %}
{{lineItems_item.variant.sku}}
{% endfor %}, {% for lineItems_item in order.lineItems %}
{{lineItems_item.quantity}}
{% endfor %}
Use a For each action to loop over the lineItems and call the Sheets action for each of those line items. This has been answered several times in this thread, with screenshots, if you scroll up.
Your liquid is looping over the order.lineitems instead of the lineItems from the loop.
Click “Add a variable”, choose the lineItem from the for each loop, and then the values you want. Once you see the syntax, it should be easy to adjust the rest. You shouldn’t need to loop over the lineItems any more, so it should be a bit simpler