diff --git a/packages/editor-ui/src/components/NodeSettings.vue b/packages/editor-ui/src/components/NodeSettings.vue index bff37056f6..ea5f37ea15 100644 --- a/packages/editor-ui/src/components/NodeSettings.vue +++ b/packages/editor-ui/src/components/NodeSettings.vue @@ -25,7 +25,7 @@ The node does not have any parameters. - + @@ -142,6 +142,7 @@ export default mixins( nodeValues: { color: '#ff0000', alwaysOutputData: false, + executeOnce: false, notesInFlow: false, continueOnFail: false, retryOnFail: false, @@ -187,6 +188,14 @@ export default mixins( noDataExpression: true, description: 'If activated and the node does not have any data for the first output,
it returns an empty item anyway. Be careful setting this on
IF-Nodes as it could easily cause an infinite loop.', }, + { + displayName: 'Execute Once', + name: 'executeOnce', + type: 'boolean', + default: false, + noDataExpression: true, + description: 'Instead of executing once per item does it only execute once with the data of the first item.', + }, { displayName: 'Retry On Fail', name: 'retryOnFail', @@ -442,6 +451,11 @@ export default mixins( Vue.set(this.nodeValues, 'alwaysOutputData', this.node.alwaysOutputData); } + if (this.node.executeOnce) { + foundNodeSettings.push('executeOnce'); + Vue.set(this.nodeValues, 'executeOnce', this.node.executeOnce); + } + if (this.node.continueOnFail) { foundNodeSettings.push('continueOnFail'); Vue.set(this.nodeValues, 'continueOnFail', this.node.continueOnFail); diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 52155e0090..9a9995f557 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -337,6 +337,7 @@ export interface INode { maxTries?: number; waitBetweenTries?: number; alwaysOutputData?: boolean; + executeOnce?: boolean; continueOnFail?: boolean; parameters: INodeParameters; credentials?: INodeCredentials; diff --git a/packages/workflow/src/Workflow.ts b/packages/workflow/src/Workflow.ts index e6d3db461e..501e7f0de9 100644 --- a/packages/workflow/src/Workflow.ts +++ b/packages/workflow/src/Workflow.ts @@ -1128,6 +1128,18 @@ export class Workflow { throw error; } + if (node.executeOnce === true) { + // If node should be executed only use only the first input item + connectionInputData = connectionInputData.slice(0, 1); + const newInputData: ITaskDataConnections = {}; + for (const inputName of Object.keys(inputData)) { + newInputData[inputName] = inputData[inputName].map(input => { + return input && input.slice(0, 1); + }); + } + inputData = newInputData; + } + if (nodeType.executeSingle) { const returnPromises: Array> = [];