How can I use Flow to add order rows to a Google sheet?

Hi!

The code I used is the same from above:

function result(range) { //range is a list of rows row_delimiter = “##” col_delimiter = “::” col_split_index = 1 //this is the column to do the split on //get number of columns in the split //var split1 = range[0][col_split_index].split(row_delimiter); //var num_col_split = split1.split(col_delimiter).length; var output = ; //loop over the rows for(var r=0, rLen=range.length; r<rLen; r++) { //loop over the column to be split to get the new number of rows var split_rows = range[r][col_split_index].split(row_delimiter); //get the column to split on for(var sr = 0, srLen=split_rows.length; sr<srLen; sr++) { var new_row = ; //loop over each column for(var c=0, cLen=range[0].length; c<cLen; c++) { if(c != col_split_index) { //if it’s the column that was split, just save that split text to the column new_row.push(range[r][c]); //get the field for this row/column } else { //loop over the columns in the split var split_cols = split_rows[sr].split(col_delimiter); for(var sc=0, scLen=split_cols.length; sc<scLen; sc++) { new_row.push(split_cols[sc]); } } } output.push(new_row); //add this row to the list } } return output } /* range looks like: [r1[col1, col2, col3a::val3a##col3b::val3b, col4], r2[col21, col22, col23a::val23a##col23b::val23b, col24]] which should be transformed to look like: col1, col2, col3a, val3a, col4 col1, col2, col3a, val3b, col4 col21, col22, col23a, val23a, col24 col21, col22, col23a, val23b, col24 */

I still run into loading errors occasionally. It appears to be triggered when data is added to the spreadsheet from Shopify Flow.

Hey Paul

Is it possible to escape the comma? I want to insert a formulae into a field from Shopify flow but I need commas in that formulae. I have tried wrapping the whole string in double and single quotes but neither seems to work. This is what I am trying to insert:

=IF(("{{order.createdAt | date: "%Y-%m-%d %H:%M:%S"}}"-"{{order.customer.emailMarketingConsent.consentUpdatedAt | date: "%Y-%m-%d %H:%M:%S"}}")

Cheers

Luke

I tested this…

Add a backslash to commas you don’t want to send as new columns.

1 Like

Hello,
Would someone please be able to paste the full script after these changes were made? Would like to copy it all over to my fulfilment sheet but I am a bit lost with what the final result was!

There are multiple scripts so it’s not clear which you are asking for.

I’ll add…now that “For Each” loops are available, you can usually loop over line items using that action and call the Sheets action for each line item without code.

Can you show me, how can I connect Shopify Flow with Google Sheet?

How do I send data to a spreadsheet by Shopify flow?

Thanks