feat(Google Sheets Node): Option how to combine filters when reading rows (#8652)
This commit is contained in:
@@ -136,7 +136,7 @@ export const description: SheetProperties = [
|
||||
show: {
|
||||
resource: ['sheet'],
|
||||
operation: ['append'],
|
||||
'@version': [4, 4.1, 4.2],
|
||||
'@version': [{ _cnd: { gte: 4 } }],
|
||||
},
|
||||
hide: {
|
||||
...untilSheetSelected,
|
||||
|
||||
@@ -172,7 +172,7 @@ export const description: SheetProperties = [
|
||||
show: {
|
||||
resource: ['sheet'],
|
||||
operation: ['appendOrUpdate'],
|
||||
'@version': [4, 4.1, 4.2],
|
||||
'@version': [{ _cnd: { gte: 4 } }],
|
||||
},
|
||||
hide: {
|
||||
...untilSheetSelected,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import type { GoogleSheet } from '../../helpers/GoogleSheet';
|
||||
import {
|
||||
getRangeString,
|
||||
@@ -15,6 +20,27 @@ import type {
|
||||
|
||||
import { dataLocationOnSheet, outputFormatting } from './commonDescription';
|
||||
|
||||
const combineFiltersOptions: INodeProperties = {
|
||||
displayName: 'Combine Filters',
|
||||
name: 'combineFilters',
|
||||
type: 'options',
|
||||
description:
|
||||
'How to combine the conditions defined in "Filters": AND requires all conditions to be true, OR requires at least one condition to be true',
|
||||
options: [
|
||||
{
|
||||
name: 'AND',
|
||||
value: 'AND',
|
||||
description: 'Only rows that meet all the conditions are selected',
|
||||
},
|
||||
{
|
||||
name: 'OR',
|
||||
value: 'OR',
|
||||
description: 'Rows that meet at least one condition are selected',
|
||||
},
|
||||
],
|
||||
default: 'AND',
|
||||
};
|
||||
|
||||
export const description: SheetProperties = [
|
||||
{
|
||||
displayName: 'Filters',
|
||||
@@ -64,6 +90,33 @@ export const description: SheetProperties = [
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
...combineFiltersOptions,
|
||||
default: 'OR',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'@version': [{ _cnd: { lt: 4.3 } }],
|
||||
resource: ['sheet'],
|
||||
operation: ['read'],
|
||||
},
|
||||
hide: {
|
||||
...untilSheetSelected,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
...combineFiltersOptions,
|
||||
displayOptions: {
|
||||
show: {
|
||||
'@version': [{ _cnd: { gte: 4.3 } }],
|
||||
resource: ['sheet'],
|
||||
operation: ['read'],
|
||||
},
|
||||
hide: {
|
||||
...untilSheetSelected,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
@@ -178,19 +231,24 @@ export async function execute(
|
||||
}
|
||||
}
|
||||
|
||||
const combineFilters = this.getNodeParameter('combineFilters', itemIndex, 'OR') as
|
||||
| 'AND'
|
||||
| 'OR';
|
||||
|
||||
responseData = await sheet.lookupValues(
|
||||
data as string[][],
|
||||
headerRow,
|
||||
firstDataRow,
|
||||
lookupValues,
|
||||
returnAllMatches,
|
||||
combineFilters,
|
||||
);
|
||||
} else {
|
||||
responseData = sheet.structureArrayDataByColumn(data as string[][], headerRow, firstDataRow);
|
||||
}
|
||||
|
||||
returnData.push(
|
||||
...responseData.map((item, index) => {
|
||||
...responseData.map((item) => {
|
||||
return {
|
||||
json: item,
|
||||
pairedItem: { item: itemIndex },
|
||||
|
||||
@@ -172,7 +172,7 @@ export const description: SheetProperties = [
|
||||
show: {
|
||||
resource: ['sheet'],
|
||||
operation: ['update'],
|
||||
'@version': [4, 4.1, 4.2],
|
||||
'@version': [{ _cnd: { gte: 4 } }],
|
||||
},
|
||||
hide: {
|
||||
...untilSheetSelected,
|
||||
|
||||
Reference in New Issue
Block a user