{"record":{"id":"fdebb3af16d5b272","repo":"flowable/flowable-engine","slug":"no-multi-instance-execution-found-for-activity-id","errorCode":null,"errorMessage":"No multi instance execution found for activity id ","messagePattern":"No multi instance execution found for activity id ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddMultiInstanceExecutionCmd.java","lineNumber":58,"sourceCode":"    \n    protected String activityId;\n    protected String parentExecutionId;\n    protected Map<String, Object> executionVariables;\n\n    public AddMultiInstanceExecutionCmd(String activityId, String parentExecutionId, Map<String, Object> executionVariables) {\n        this.activityId = activityId;\n        this.parentExecutionId = parentExecutionId;\n        this.executionVariables = executionVariables;\n    }\n\n    @Override\n    public Execution execute(CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();\n        \n        ExecutionEntity miExecution = searchForMultiInstanceActivity(activityId, parentExecutionId, executionEntityManager);\n        \n        if (miExecution == null) {\n            throw new FlowableException(\"No multi instance execution found for activity id \" + activityId);\n        }\n        \n        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, miExecution.getProcessDefinitionId())) {\n            throw new FlowableException(\"Flowable 5 process definitions are not supported\");\n        }\n        \n        ExecutionEntity childExecution = executionEntityManager.createChildExecution(miExecution);\n        childExecution.setCurrentFlowElement(miExecution.getCurrentFlowElement());\n        \n        BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(miExecution.getProcessDefinitionId());\n        Activity miActivityElement = (Activity) bpmnModel.getFlowElement(miExecution.getActivityId());\n        MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = miActivityElement.getLoopCharacteristics();\n        \n        Integer currentNumberOfInstances = (Integer) miExecution.getVariable(NUMBER_OF_INSTANCES);\n        miExecution.setVariableLocal(NUMBER_OF_INSTANCES, currentNumberOfInstances + 1);\n        \n        if (executionVariables != null) {\n            childExecution.setVariablesLocal(executionVariables);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddMultiInstanceExecutionCmd.java#L40-L76","documentation":"FlowableException thrown in AddMultiInstanceExecutionCmd.execute when searchForMultiInstanceActivity cannot locate a multi-instance (MI) execution for the given activityId under the given parentExecutionId. Dynamic MI execution addition (runtimeService.addMultiInstanceExecution) only works on activities whose current execution structure is multi-instance.","triggerScenarios":"Calling runtimeService.addMultiInstanceExecution(activityId, processInstanceId, executionVariables) where activityId is not a multi-instance activity, or is one whose execution has already completed / not yet started, or parentExecutionId does not point at the execution containing the MI activity.","commonSituations":"Activity id typo or mismatch with the BPMN XML; trying to add executions to a parallel/sequential MI task that has finished; calling against a subprocess activity without supplying the correct parent execution; process model changed (MI marker removed) after ids were baked into calling code.","solutions":["Confirm the activityId in the BPMN XML actually has multiInstanceLoopCharacteristics and is currently active in the process instance.","Check the activity is in an active state (use runtimeService.createExecutionQuery().activityId(...) or process instance diagram) before adding executions.","If the activity is inside a subprocess/callActivity scope, pass the correct parentExecutionId or use the process instance id of the right scope."],"exampleFix":"// before\nruntimeService.addMultiInstanceExecution(\"approveTask\", processInstanceId, vars); // task not MI or not active\n// after\nExecution mi = runtimeService.createExecutionQuery()\n    .processInstanceId(processInstanceId)\n    .activityId(\"approveTask\").singleResult();\nif (mi != null) {\n    runtimeService.addMultiInstanceExecution(\"approveTask\", processInstanceId, vars);\n}","handlingStrategy":"validation","validationCode":"long active = runtimeService.createExecutionQuery()\n    .processInstanceId(processInstanceId)\n    .activityId(activityId).count();\nif (active == 0) {\n    // no active execution at that activity: cannot add MI executions\n}","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.addMultiInstanceExecution(activityId, piId, vars);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"No multi instance execution found\")) {\n        // verify BPMN model has multiInstanceLoopCharacteristics on activityId\n    }\n    throw e;\n}","preventionTips":["Extract activity ids from the deployed BpmnModel instead of hardcoding strings.","Verify the activity has multiInstanceLoopCharacteristics before dynamic MI calls.","Check the MI activity is currently active (not completed/not yet reached)."],"tags":["flowable","multi-instance","not-found","dynamic-bpmn"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}