{"record":{"id":"d88c7c0472c1c373","repo":"flowable/flowable-engine","slug":"cannot-trigger-case-task-plan-item-instance-no-r","errorCode":null,"errorMessage":"Cannot trigger case task plan item instance : no reference id set","messagePattern":"Cannot trigger case task plan item instance : no reference id set","errorType":"exception","errorClass":"FlowableIllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/CaseTaskActivityBehavior.java","lineNumber":169,"sourceCode":"        if (variablesFromFormSubmission != null && !variablesFromFormSubmission.isEmpty()) {\n            // The variablesFromFormSubmission can only be non null if there was formInfo\n            cmmnEngineConfiguration.getFormFieldHandler()\n                    .handleFormFieldsOnSubmit(variableInfo.formInfo, null, null, caseInstanceEntity.getId(), ScopeTypes.CMMN,\n                            variablesFromFormSubmission, caseInstanceEntity.getTenantId());\n        }\n\n        if (!blocking) {\n            CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstanceEntity);\n        }\n    }\n\n    @Override\n    public void trigger(CommandContext commandContext, PlanItemInstanceEntity planItemInstance) {\n        if (!PlanItemInstanceState.ACTIVE.equals(planItemInstance.getState())) {\n            throw new FlowableIllegalStateException(\"Can only trigger a plan item that is in the ACTIVE state\");\n        }\n        if (planItemInstance.getReferenceId() == null) {\n            throw new FlowableIllegalStateException(\"Cannot trigger case task plan item instance : no reference id set\");\n        }\n        if (!ReferenceTypes.PLAN_ITEM_CHILD_CASE.equals(planItemInstance.getReferenceType())) {\n            throw new FlowableIllegalStateException(\"Cannot trigger case task plan item instance : reference type '\"\n                    + planItemInstance.getReferenceType() + \"' not supported\");\n        }\n\n        // load the case instance referenced by this case task plan item to check its current state\n        CaseInstanceEntity caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(planItemInstance.getReferenceId());\n\n        if (caseInstance != null) {\n            // Out parameters are handled here only when the case is still active (manual trigger scenario).\n            // When the child case completed normally, out parameters are already handled\n            // in ChildCaseInstanceStateChangeCallback before the child case gets deleted.\n            handleOutParameters(commandContext, planItemInstance);\n\n            if (caseInstance.getState().equals(CaseInstanceState.ACTIVE)) {\n                // Triggering the plan item (as opposed to a regular complete of the referenced case) manually terminates the case instance\n                CommandContextUtil.getAgenda(commandContext).planManualTerminateCaseInstanceOperation(planItemInstance.getReferenceId());","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/CaseTaskActivityBehavior.java#L151-L187","documentation":"When triggering a case task plan item, the behavior checks that the instance's referenceId points at the child case instance started for it. If referenceId is null, the engine has no child-case linkage to complete and throws this error. The reference is set when the case task starts the child case.","triggerScenarios":"Calling trigger on a case task plan item instance that never started a child case — e.g. the task was made non-blocking (completed immediately), the child case failed to start, or the plan item was created without executing the child-case start logic.","commonSituations":"Manually triggering a non-blocking case task; engine crash/rollback after plan item activation but before child case creation; tampering with instance data; version mismatch between parent case runtime data and engine code.","solutions":["Only trigger blocking case task plan items that actually started a child case (referenceType PLAN_ITEM_CHILD_CASE).","Verify the child case instance exists (CaseInstanceQuery by parent/plan item) before completing.","If the child case failed to start, fix the underlying error and let the case task be completed through the normal completion path.","Do not manually complete non-blocking case tasks; they complete automatically."],"exampleFix":"// before\nruntimeService.triggerPlanItemInstance(nonBlockingCaseTaskPiiId); // referenceId == null\n// after\nPlanItemInstance pii = runtimeService.createPlanItemInstanceQuery()\n    .planItemInstanceId(id).singleResult();\nif (pii.getReferenceId() != null) {\n    runtimeService.triggerPlanItemInstance(id);\n}","handlingStrategy":"validation","validationCode":"PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(id).singleResult();\nboolean triggerable = pii != null && pii.getReferenceId() != null;\n","typeGuard":null,"tryCatchPattern":"try {\n    cmmnRuntimeService.triggerPlanItemInstance(id);\n} catch (FlowableIllegalStateException e) {\n    if (e.getMessage().contains(\"no reference id set\")) {\n        // plan item never started a child case; do not complete manually\n    }\n}","preventionTips":["Only trigger blocking case tasks that started a child case","Never manually complete non-blocking case tasks","Verify the child case instance was created after activation","Monitor for engine crashes between activation and child-case start"],"tags":["cmmn","case-task","reference-id","child-case"],"backgroundTag":"null-argument","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"}