fix(Google Sheets Node): Insert data if sheet is empty instead of error (#10942)

This commit is contained in:
Michael Kret
2024-09-24 18:41:07 +03:00
committed by GitHub
parent ad60d49b42
commit c75990e063
5 changed files with 178 additions and 6 deletions

View File

@@ -257,7 +257,7 @@ export async function execute(
}
}
const dataMode =
let dataMode =
nodeVersion < 4
? (this.getNodeParameter('dataMode', 0) as string)
: (this.getNodeParameter('columns.mappingMode', 0) as string);
@@ -267,10 +267,14 @@ export async function execute(
const sheetData = (await sheet.getData(sheetName, 'FORMATTED_VALUE')) ?? [];
if (!sheetData[keyRowIndex] && dataMode !== 'autoMapInputData') {
throw new NodeOperationError(
this.getNode(),
`Could not retrieve the column names from row ${keyRowIndex + 1}`,
);
if (!sheetData.length) {
dataMode = 'autoMapInputData';
} else {
throw new NodeOperationError(
this.getNode(),
`Could not retrieve the column names from row ${keyRowIndex + 1}`,
);
}
}
columnNames = sheetData[keyRowIndex] ?? [];