I’d like to update or append or create new sheet on a google spreadsheet that has for 2 columns reference and price and each of the values from the json in its own row :
This would be possible using the Function node and a JavaScript snippet like this:
// Create array to hold our newly created items
let results = [];
// Loop through all input items (which have array values in the reference and cost fields)
for (item of items) {
// Loop through the number of items in the reference array for the current item
for (let i = 0; i < item.json.reference.length; i++) {
// Check if we also have a corresponding value in the cost field
if (item.json.cost[i]) {
// Push the result to our results
results.push({
json: {
reference: item.json.reference[i],
cost: item.json.cost[i]
}
});
}
}
}
// Return the results to the next node
return results;
Hi @Uness, I hope you’re well? I quickly wanted to follow up on this as I was discussing your task with @harshil1712 a few minutes back. He suggested using multiple Item Lists nodes here to replace the JavaScript snippet. So if you prefer an approach without using the Function node, this would be a possible way to achieve this: