The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Do not run loop when iterator is skipped (#18964)
Thomas Trompette6c1db2e7fb31
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/__tests__/workflow-executor.workspace-service.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/__tests__/workflow-executor.workspace-service.spec.tsindex 9137da2d24e..11f92fa2b61 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/__tests__/workflow-executor.workspace-service.spec.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/__tests__/workflow-executor.workspace-service.spec.ts@@ -529,6 +529,30 @@ describe('WorkflowExecutorWorkspaceService', () => {});});+ it('should return nextStepIds for a skipped iterator instead of entering the loop', async () => {+ const step = {+ id: 'iterator-1',+ type: WorkflowActionType.ITERATOR,+ nextStepIds: ['after-loop'],+ settings: {+ input: {+ initialLoopStepIds: ['loop-step-1'],+ },+ },+ } as WorkflowAction;++ const result = await service.getNextStepIdsToExecute({+ executedStep: step,+ executedStepOutput: {+ shouldSkipStepExecution: true,+ },+ });++ expect(result).toEqual({+ nextStepIdsToExecute: ['after-loop'],+ });+ });+it('should return nextStepIdsToFailSafely for all branches when if-else is fail-safe', async () => {const step = {id: 'if-else-1',diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.tsindex 7f0bda4cbef..212fb1715f2 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts@@ -253,7 +253,8 @@ export class WorkflowExecutorWorkspaceService {if (!iteratorStepResult?.hasProcessedAllItems &&- !executedStepOutput.shouldFailSafely+ !executedStepOutput.shouldFailSafely &&+ !executedStepOutput.shouldSkipStepExecution) {const nextStepIdsToExecute = isString(executedStep.settings.input.initialLoopStepIds,