Skip to content

Commit

Permalink
fix(Google Sheets Node): Update to returnAllMatches option (n8n-io#10440
Browse files Browse the repository at this point in the history
)

Co-authored-by: Shireen Missi <[email protected]>
  • Loading branch information
michael-radency and ShireenMissi authored Aug 16, 2024
1 parent ce46bf5 commit f7fb02e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class GoogleSheets extends VersionedNodeType {
name: 'googleSheets',
icon: 'file:googleSheets.svg',
group: ['input', 'output'],
defaultVersion: 4.4,
defaultVersion: 4.5,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Read, update and write data to Google Sheets',
};
Expand All @@ -25,6 +25,7 @@ export class GoogleSheets extends VersionedNodeType {
4.2: new GoogleSheetsV2(baseDescription),
4.3: new GoogleSheetsV2(baseDescription),
4.4: new GoogleSheetsV2(baseDescription),
4.5: new GoogleSheetsV2(baseDescription),
};

super(nodeVersions, baseDescription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ export const description: SheetProperties = [
options: [
dataLocationOnSheet,
outputFormatting,
{
displayName: 'Return only First Matching Row',
name: 'returnFirstMatch',
type: 'boolean',
default: false,
description:
'Whether to select the first row of the sheet or the first matching row (if filters are set)',
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 4.5 } }],
},
},
},
{
displayName: 'When Filter Has Multiple Matches',
name: 'returnAllMatches',
Expand All @@ -154,6 +167,11 @@ export const description: SheetProperties = [
],
description:
'By default only the first result gets returned, Set to "Return All Matches" to get multiple matches',
displayOptions: {
show: {
'@version': [{ _cnd: { lt: 4.5 } }],
},
},
},
],
},
Expand Down Expand Up @@ -219,7 +237,12 @@ export async function execute(
const inputData = data as string[][];

if (lookupValues.length) {
const returnAllMatches = options.returnAllMatches === 'returnAllMatches' ? true : false;
let returnAllMatches;
if (nodeVersion < 4.5) {
returnAllMatches = options.returnAllMatches === 'returnAllMatches' ? true : false;
} else {
returnAllMatches = options.returnFirstMatch ? false : true;
}

if (nodeVersion <= 4.1) {
for (let i = 1; i < items.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const versionDescription: INodeTypeDescription = {
name: 'googleSheets',
icon: 'file:googleSheets.svg',
group: ['input', 'output'],
version: [3, 4, 4.1, 4.2, 4.3, 4.4],
version: [3, 4, 4.1, 4.2, 4.3, 4.4, 4.5],
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Read, update and write data to Google Sheets',
defaults: {
Expand Down

0 comments on commit f7fb02e

Please sign in to comment.