mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Execute Sub-workflow Node): Improve paired item handling for child workflows (#17065)
This commit is contained in:
@@ -7,10 +7,12 @@ import type {
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { findPairedItemTroughWorkflowData } from './../../../utils/workflow-backtracking';
|
||||
import { getWorkflowInfo } from './GenericFunctions';
|
||||
import { localResourceMapping } from './methods';
|
||||
import { generatePairedItemData } from '../../../utils/utilities';
|
||||
import { getCurrentWorkflowInputData } from '../../../utils/workflowInputsResourceMapping/GenericFunctions';
|
||||
|
||||
export class ExecuteWorkflow implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Execute Sub-workflow',
|
||||
@@ -425,6 +427,8 @@ export class ExecuteWorkflow implements INodeType {
|
||||
return [items];
|
||||
}
|
||||
|
||||
const workflowRunData = await this.getExecutionDataById(executionResult.executionId);
|
||||
|
||||
const workflowResult = executionResult.data as INodeExecutionData[][];
|
||||
|
||||
const fallbackPairedItemData = generatePairedItemData(items.length);
|
||||
@@ -433,7 +437,20 @@ export class ExecuteWorkflow implements INodeType {
|
||||
const sameLength = output.length === items.length;
|
||||
|
||||
for (const [itemIndex, item] of output.entries()) {
|
||||
if (item.pairedItem) continue;
|
||||
if (item.pairedItem) {
|
||||
// If the item already has a paired item, we need to follow these to the start of the child workflow
|
||||
if (workflowRunData !== undefined) {
|
||||
const pairedItem = findPairedItemTroughWorkflowData(
|
||||
workflowRunData,
|
||||
item,
|
||||
itemIndex,
|
||||
);
|
||||
if (pairedItem !== undefined) {
|
||||
item.pairedItem = pairedItem;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sameLength) {
|
||||
item.pairedItem = { item: itemIndex };
|
||||
|
||||
Reference in New Issue
Block a user