The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Store history for iterator (#14771)
Thomas Trompette123202df41f7
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/iterator.workflow-action.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/iterator.workflow-action.tsindex dd247936f1d..f8c5a8340f4 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/iterator.workflow-action.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/iterator.workflow-action.ts@@ -147,28 +147,48 @@ export class IteratorWorkflowAction implements WorkflowActionInterface {});const stepInfos = workflowRunToUpdate.state.stepInfos;+ const subStepsInfos = stepIdsToReset.reduce(+ (acc, stepId) => {+ acc[stepId] = {+ status: StepStatus.NOT_STARTED,+ result: undefined,+ error: undefined,+ history: [+ ...(stepInfos[stepId]?.history ?? []),+ {+ result: stepInfos[stepId]?.result,+ error: stepInfos[stepId]?.error,+ status: stepInfos[stepId]?.status,+ },+ ],+ };++ return acc;+ },+ {} as Record<string, WorkflowRunStepInfo>,+ );++ const iteratorStepInfo = stepInfos[iteratorStepId];++ const stepInfosToUpdate = {+ ...subStepsInfos,+ [iteratorStepId]: {+ ...iteratorStepInfo,+ result: undefined,+ error: undefined,+ history: [+ ...(iteratorStepInfo?.history ?? []),+ {+ result: iteratorStepInfo?.result,+ error: iteratorStepInfo?.error,+ status: iteratorStepInfo?.status,+ },+ ],+ },+ };await this.workflowRunWorkspaceService.updateWorkflowRunStepInfos({- stepInfos: stepIdsToReset.reduce(- (acc, stepId) => {- acc[stepId] = {- status: StepStatus.NOT_STARTED,- result: undefined,- error: undefined,- history: [- ...(stepInfos[stepId]?.history ?? []),- {- result: stepInfos[stepId]?.result,- error: stepInfos[stepId]?.error,- status: stepInfos[stepId]?.status,- },- ],- };-- return acc;- },- {} as Record<string, WorkflowRunStepInfo>,- ),+ stepInfos: stepInfosToUpdate,workflowRunId,workspaceId,});