From c6646ac5117496c4e80c369739e9c57558cf059e Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:45:23 +0300 Subject: [PATCH] fix(Google Sheets Node): Add column names row if sheet is empty (#10200) Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com> --- .../nodes/Google/Sheet/v2/actions/sheet/append.operation.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts index 8b479d4ed64ff..140b107e33275 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts @@ -275,7 +275,10 @@ export async function execute( //if no trailing empty row exists in the sheet update operation will fail await sheet.appendEmptyRowsOrColumns(sheetId, 1, 0); - const lastRow = (sheetData ?? []).length + 1; + // if sheetData is undefined it means that the sheet was empty + // we did add row with column names in the first row (autoMapInputData) + // to account for that length has to be 1 and we append data in the next row + const lastRow = (sheetData ?? [{}]).length + 1; await sheet.appendSheetData({ inputData,