mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
⚡ Added continue option
This commit is contained in:
parent
6785b1ed46
commit
23503ce9f8
|
@ -20,7 +20,6 @@ import {
|
||||||
ValueRenderOption,
|
ValueRenderOption,
|
||||||
} from './GoogleSheet';
|
} from './GoogleSheet';
|
||||||
|
|
||||||
|
|
||||||
export class GoogleSheets implements INodeType {
|
export class GoogleSheets implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'Google Sheets ',
|
displayName: 'Google Sheets ',
|
||||||
|
@ -406,6 +405,21 @@ export class GoogleSheets implements INodeType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Continue If Response Is Empty',
|
||||||
|
name: 'continue',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'lookup',
|
||||||
|
'read',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'By default, the workflow stops executing if the lookup/read does not return values',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Return All Matches',
|
displayName: 'Return All Matches',
|
||||||
name: 'returnAllMatches',
|
name: 'returnAllMatches',
|
||||||
|
@ -678,7 +692,14 @@ export class GoogleSheets implements INodeType {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const returnData = await sheet.lookupValues(sheetData, keyRow, dataStartRow, lookupValues, options.returnAllMatches as boolean | undefined);
|
let returnData = await sheet.lookupValues(sheetData, keyRow, dataStartRow, lookupValues, options.returnAllMatches as boolean | undefined);
|
||||||
|
|
||||||
|
if (returnData.length === 0 && options.continue && options.returnAllMatches) {
|
||||||
|
returnData = [{}];
|
||||||
|
|
||||||
|
} else if (returnData.length === 1 && Object.keys(returnData[0]).length === 0 && !options.continue && !options.returnAllMatches) {
|
||||||
|
returnData = [];
|
||||||
|
}
|
||||||
|
|
||||||
return [this.helpers.returnJsonArray(returnData)];
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
} else if (operation === 'read') {
|
} else if (operation === 'read') {
|
||||||
|
@ -707,6 +728,10 @@ export class GoogleSheets implements INodeType {
|
||||||
returnData = sheet.structureArrayDataByColumn(sheetData, keyRow, dataStartRow);
|
returnData = sheet.structureArrayDataByColumn(sheetData, keyRow, dataStartRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (returnData.length === 0 && options.continue) {
|
||||||
|
returnData = [{}];
|
||||||
|
}
|
||||||
|
|
||||||
return [this.helpers.returnJsonArray(returnData)];
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
} else if (operation === 'update') {
|
} else if (operation === 'update') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
Loading…
Reference in a new issue