diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json new file mode 100644 index 0000000000000..9f48902cf9e9f --- /dev/null +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json @@ -0,0 +1,22 @@ +{ + "node": "n8n-nodes-base.executionData", + "nodeVersion": "1.0", + "codexVersion": "1.0", + "categories": ["Development", "Core Nodes"], + "subcategories": { + "Core Nodes": ["Helpers"] + }, + "resources": { + "credentialDocumentation": [ + { + "url": "https://docs.n8n.io/credentials/executionData" + } + ], + "primaryDocumentation": [ + { + "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executionData/" + } + ] + }, + "alias": ["Filter", "Set", "Data"] +} diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts new file mode 100644 index 0000000000000..8d68f30135b26 --- /dev/null +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts @@ -0,0 +1,111 @@ +/* eslint-disable n8n-nodes-base/node-class-description-missing-subtitle */ +import type { + IDataObject, + IExecuteFunctions, + INodeExecutionData, + INodeType, + INodeTypeDescription, +} from 'n8n-workflow'; + +export class ExecutionData implements INodeType { + description: INodeTypeDescription = { + displayName: 'Execution Data', + name: 'executionData', + icon: 'fa:tasks', + group: ['input'], + version: 1, + description: 'Add execution data for search', + defaults: { + name: 'Execution Data', + color: '#29A568', + }, + inputs: ['main'], + outputs: ['main'], + properties: [ + { + displayName: + "Use this node to save fields you want to use later to easily find an execution (e.g. a user ID). You'll be able to search by this data in the 'executions' tab.
This feature is available on our Pro and Enterprise plans. More Info.", + name: 'notice', + type: 'notice', + default: '', + }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + default: 'save', + noDataExpression: true, + options: [ + { + // eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased + name: 'Save Execution Data for Search', + value: 'save', + action: 'Save execution data for search', + }, + ], + }, + { + displayName: 'Data to Save', + name: 'dataToSave', + placeholder: 'Add Saved Field', + type: 'fixedCollection', + typeOptions: { + multipleValueButtonText: 'Add Saved Field', + multipleValues: true, + }, + displayOptions: { + show: { + operation: ['save'], + }, + }, + default: {}, + options: [ + { + displayName: 'Values', + name: 'values', + values: [ + { + displayName: 'Key', + name: 'key', + type: 'string', + default: '', + placeholder: 'e.g. myKey', + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + placeholder: 'e.g. myValue', + }, + ], + }, + ], + }, + ], + }; + + async execute(this: IExecuteFunctions): Promise { + const context = this.getWorkflowDataProxy(0); + + const items = this.getInputData(); + const operations = this.getNodeParameter('operation', 0); + + if (operations === 'save') { + for (let i = 0; i < items.length; i++) { + const dataToSave = + ((this.getNodeParameter('dataToSave', i, {}) as IDataObject).values as IDataObject[]) || + []; + + const values = dataToSave.reduce((acc, { key, value }) => { + acc[key as string] = value; + return acc; + }, {} as IDataObject); + + context.$execution.customData.setAll(values); + } + } + + return [items]; + } +} diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 150ef66100327..f4b77de687e4e 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -447,6 +447,7 @@ "dist/nodes/ExecuteCommand/ExecuteCommand.node.js", "dist/nodes/ExecuteWorkflow/ExecuteWorkflow.node.js", "dist/nodes/ExecuteWorkflowTrigger/ExecuteWorkflowTrigger.node.js", + "dist/nodes/ExecutionData/ExecutionData.node.js", "dist/nodes/Facebook/FacebookGraphApi.node.js", "dist/nodes/Facebook/FacebookTrigger.node.js", "dist/nodes/Figma/FigmaTrigger.node.js",