In the below digram, when one of the milestone is reached I want to disable the other. How to achieve this in java code?
I tried the below and it didn’t work, getting exception like below. what am I missing? Any advise to model this scenario better?
I dont want to exit the case when the milestone is reached, thats why I didnt attach an exit criteria
Caused by: org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException: ENGINE-05006 Could not perform transition 'disable on case execution with id ‘e6712463-24b0-11ea-922f-0242a1f091a0’.Reason: It is not possible to disable the case execution which is associated with a milestone
public void notify(DelegateCaseExecution caseExecution) throws Exception {
System.out.println(" --- Disabling some stuff ---");
String caseInstanceId = caseExecution.getCaseInstanceId();
List<CaseExecution> caseExecutions = caseExecution.getProcessEngineServices().getCaseService().createCaseExecutionQuery().caseInstanceId(caseInstanceId).list();
for (CaseExecution otherCaseExecution : caseExecutions) {
if (otherCaseExecution.isEnabled()) {
caseExecution.getProcessEngineServices().getCaseService().disableCaseExecution(otherCaseExecution.getId());
}
System.out.println(otherCaseExecution.getActivityName() + " -> " + ((CaseExecutionEntity)otherCaseExecution).getCurrentState().toString());
}