Starting Case Task (CMMN) in Camunda BPM 7.5 not working with TaskService

Hello,

i’m trying to complete a common Human Task in CMMN-Process by using the Task Service, but in step 2 i get always a List with size 0. Until version 7.4 i have done it in the following way:

  1. Get Case Executions by caseInstanceId (That is working fine and gives me in my case one active CasePlanModel and 3 tasks in status enabled

List CaseExecution caseExecutions = engine.getCaseService()
.createCaseExecutionQuery()
.caseInstanceId(caseInstanceId)
.list();

  1. Let’s say i choose one execution in the list and want to get the corresponding task. For example:

execution = caseExecutions.get(0)
Task task = engine.getTaskService().createTaskQuery().caseExecutionId(execution.getId()).list().get(0);

In Version 7.4 that was working fine (got this apporach from an underwriting CMMN example in the git repository. In 7.5 The list of the query is allways empty. I have tried it in the full distribution and with the manual installation with myMSQL-Database. In both cases this way ist not working anymore In the sql-scripts i could see, that in the table act_ru_case_execution there is a column act_ID, which is not declared as a foreign key. Is that right and maybe the reaseon, why this is not working anymore?

  1. Complete the task (Because 2 is not working i have no task to complete…

this.engine.getTaskService().complete(task.getId(), variables);

  1. How can i complete a common humanTask of a CMMN-process in Camunda version 7.5?
  2. In which case the case in step 2) the query will give me a list with more than one Object? Is there not a 1:1 relationship between task and case execution?

I’m a little mit in pressure in my master-thesis and would be very grateful, if you can help me to complete a human task (or any other task ) in a CMMN-Processinstance.

In the appendix you can see an example CaseExecution object:

Thanks a lot!

Hi Andy,

I have found a simulare problem.

To solve the complete problem I use the caseService.completeCaseExecution(“aCaseExecutionId”) function.

But it is documentate, that both ways should work:

https://docs.camunda.org/manual/7.5/reference/cmmn11/tasks/human-task/

If the work associated with the human task is done, it is possible to complete the human task manually using the CaseService as follows:
caseService.completeCaseExecution("aCaseExecutionId");

This completes the created task as well.
Instead of using the CaseService it is also possible to use the TaskService to complete a human task:
taskService.complete("aTaskId");

Kind regard,
Bernd

Thank you! I will use the completeCaseExecution method. By the way i found out, that there are no Tasks in the table available. They are only available in a caseExecution Query. The following query gives ´me an empty list for a valid caseInstance.
List<Task> list = this.engine.getTaskService().createTaskQuery().caseInstanceId(caseInstanceId).list();

This Query gives me all case Executions with all activities:
List<CaseExecution> caseExecutions = this.engine.getCaseService().createCaseExecutionQuery().caseInstanceId(caseInstanceId).list();

Do i have to insert tasks manually or is it a bug?

Best regard,
Andy

Hi @Andy,

I think that the corresponding case execution is in the state ENABLED. In CMMN a Task instance is created when a humanTask plan item reaches the ACTIVE state. Only then you can find a Task via TaskService#createTaskQuery. For further details have a look into the documentation about the lifecycle of plan items 1.

Cheers,
Roman