n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
46.58k stars 6.72k forks source link

Google Sheets not inserting into correct sheet in document #10344

Open Nick-PDS opened 1 month ago

Nick-PDS commented 1 month ago

Bug Description

I am using the "Loop Over Items" node to split my items into batches of 30 to insert into a Google Sheet that is inside a document. The sheet it inserts to is with the item and the Google Sheets node uses an expression to set the sheet. The result displayed in the expression of the sheet ID when testing the workflow IS CORRECT, but the actual execution seems to be messing up because looking at the sheet itself it all went into the first item's sheet ID.

This is happening specifically for the "Append or Update Row" with the resource as "Sheet Within Document"

I was able to fix this issue by reducing the batch size to 1 and then adding an IF statement to check if the Loop's runIndex is divisible by 30 to go to a "Wait" node so I don't trigger any rate limits from Google.

To Reproduce

  1. Insert a Loop Over Items node with a batch size of 30
  2. My specific case, I had 14 items where half of them had one sheet id and other half had a different sheet id in the same document
  3. Use a combination of a "Edit Set" node to map the columns and "Google Sheets" node with the resource as "Sheet Within Document" and operation is "Append or Update Row" where the document is selected from a list and the sheet is By ID that is set via expression where each item has a sheetId it is supposed to go into
  4. If reproduced, all items will go wherever the first item's sheetId is set to

Expected behavior

Each item is supposed to go into it designated sheetId if batched by more than one.

Operating System

Ubuntu Linux 22.02

n8n Version

1.52.2

Node.js Version

20.15.0

Database

SQLite (default)

Execution mode

main (default)

Joffcom commented 1 month ago

Hey @Nick-PDS,

We have created an internal ticket to look into this which we will be tracking as "GHC-146"