mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Summarize Node): Option to continue when field to summarize can't be found in any items (#9118)
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
fieldValueGetter,
|
||||
splitData,
|
||||
} from './utils';
|
||||
import { generatePairedItemData } from '../../../utils/utilities';
|
||||
|
||||
export class Summarize implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -239,6 +240,14 @@ export class Summarize implements INodeType {
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Continue if Field Not Found',
|
||||
name: 'continueIfFieldNotFound',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description:
|
||||
"Whether to continue if field to summarize can't be found in any items and return single empty item, owerwise an error would be thrown",
|
||||
},
|
||||
{
|
||||
displayName: 'Disable Dot Notation',
|
||||
name: 'disableDotNotation',
|
||||
@@ -304,7 +313,17 @@ export class Summarize implements INodeType {
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
|
||||
if (nodeVersion < 2.1) {
|
||||
checkIfFieldExists.call(this, newItems, fieldsToSummarize, getValue);
|
||||
try {
|
||||
checkIfFieldExists.call(this, newItems, fieldsToSummarize, getValue);
|
||||
} catch (error) {
|
||||
if (options.continueIfFieldNotFound) {
|
||||
const itemData = generatePairedItemData(items.length);
|
||||
|
||||
return [[{ json: {}, pairedItem: itemData }]];
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const aggregationResult = splitData(
|
||||
|
||||
Reference in New Issue
Block a user