{"record":{"id":"e36197e0210ce232","repo":"flowable/flowable-engine","slug":"no-active-or-enabled-plan-item-instances-found-for","errorCode":null,"errorMessage":"No active or enabled plan item instances found for plan item definition <planItemDefinitionId>","messagePattern":"No active or enabled plan item instances found for plan item definition <planItemDefinitionId>","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/AbstractCmmnDynamicStateManager.java","lineNumber":443,"sourceCode":"                if (PlanItemInstanceState.ACTIVE.equals(planItemInstance.getState()) || PlanItemInstanceState.ENABLED.equals(planItemInstance.getState())) {\n                    if (existingPlanItemInstance != null) {\n                        throw new FlowableException(\"multiple active or enabled plan item instances found for plan item definition \" + planItemDefinitionMapping.getPlanItemDefinitionId());\n                    } else {\n                        existingPlanItemInstance = planItemInstance;\n                    }\n                }\n                if (!PlanItemInstanceState.AVAILABLE.equals(planItemInstance.getState())) {\n                    allExistingPlanItemsAreAvailable = false;\n                }\n            }\n\n            if (allExistingPlanItemsAreAvailable) {\n                // all existing plan items are available, we can continue without any changes\n                continue;\n            }\n            \n            if (existingPlanItemInstance == null) {\n                throw new FlowableException(\"No active or enabled plan item instances found for plan item definition \" + planItemDefinitionMapping.getPlanItemDefinitionId());\n            }\n            \n            PlanItemInstanceEntity existingPlanItemInstanceEntity = (PlanItemInstanceEntity) existingPlanItemInstance;\n\n            if (!evaluateCondition(existingPlanItemInstanceEntity, planItemDefinitionMapping)) {\n                continue;\n            }\n\n            if (existingPlanItemInstanceEntity.getPlanItem().getPlanItemDefinition() instanceof HumanTask) {\n                TaskService taskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService();\n                List<TaskEntity> taskEntities = taskService.findTasksBySubScopeIdScopeType(existingPlanItemInstanceEntity.getId(), ScopeTypes.CMMN);\n                if (taskEntities == null || taskEntities.isEmpty()) {\n                    throw new FlowableException(\"No task entity found for plan item instance \" + existingPlanItemInstanceEntity.getId());\n                }\n\n                // Should be only one\n                for (TaskEntity taskEntity : taskEntities) {\n                    if (!taskEntity.isDeleted()) {","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/AbstractCmmnDynamicStateManager.java#L425-L461","documentation":"When changing plan item instances to the AVAILABLE state, Flowable requires the current instance it is about to move to be ACTIVE or ENABLED. If none of the existing instances for the given plan item definition are active/enabled (i.e. no instance to move from), this FlowableException is thrown.","triggerScenarios":"Calling changePlanItemState with a planItemDefinitionMapping whose plan item definition has no plan item instance in ACTIVE or ENABLED state in the case instance (all are AVAILABLE, COMPLETED, unavailable, or simply do not exist).","commonSituations":"Attempting to move a plan item that has not yet been created/triggered in the case; the case has already progressed past the plan item; wrong case instance id so no matching instances exist; plan item id typo so the lookup matches nothing.","solutions":["Verify the plan item instance exists and is in ACTIVE or ENABLED state via PlanItemInstanceQuery before changing state","Complete or trigger the plan item so it reaches ACTIVE state first, then move it","Check the case instance id and case definition version are correct","Use mapIncompleteChildrenForPlanItemDefinition or a state change that supports non-active source states"],"exampleFix":"// before\ncmmnRuntimeService.changePlanItemState(caseInstanceId, changeState); // throws if not active\n// after\nPlanItemInstance pis = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .caseInstanceId(caseInstanceId).planItemDefinitionId(\"taskDef\")\n    .state(PlanItemInstanceState.ACTIVE).singleResult();\nif (pis != null) {\n    cmmnRuntimeService.changePlanItemState(caseInstanceId, changeState);\n}","handlingStrategy":"validation","validationCode":"PlanItemInstance pis = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .caseInstanceId(caseInstanceId).planItemDefinitionId(defId)\n    .state(PlanItemInstanceState.ACTIVE).singleResult();\nif (pis == null) throw new IllegalStateException(\"No ACTIVE instance of \" + defId + \" to move\");","typeGuard":null,"tryCatchPattern":"try {\n    cmmnRuntimeService.changePlanItemState(caseInstanceId, changeState);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"No active or enabled plan item instances\")) {\n        // skip or trigger the plan item first\n    } else {\n        throw e;\n    }\n}","preventionTips":["Check plan item instance state with PlanItemInstanceQuery before changing state","Ensure the plan item has been created/triggered before attempting moves","Confirm the case instance id is correct and the case hasn't already progressed"],"tags":["cmmn","dynamic-state","plan-item","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}