Is there a way to get the tasks which in a specified sub process instance?

Hello everyone.

Here is the process

Let`s asume the process instance of above process definition have two task instance.
The first is Task A
The second is Task B

That means in the process instance have two running token on the two user task.

Is there a way to get the Task A only ? In other word that means : How to get the tasks which in the SubProcessA sub process ?

I know the Camunda java api does not provided such api. But is there a way I can use mybatis directly connect to the ACT_RU_TASK table get the result ?

I researched a lot about the fields of the ACT_RU_TASK table but did not found such field which identify the parent activity of a task.

But there is no such field can help me to know which is the parent activity of a task.

Questions:

  1. Is there a way to get the tasks which in a specified sub process instance ?
  2. Is there a way can get the parent activity of a userTask instance from the tables of Camunda?
    What is the meaning of “the tables” ?
    I mean those tables :

Thanks.

@himly why can’t you query by Task definition key or task name?

Thank you for your reply.

Because In a sub process maybe have more than one task.
So the question is not about how to get specified tasks but about how to get all tasks in a specified sub process instance.

That means I dont know the names of the tasks dont know the definition key of the tasks dont know how much tasks exists.

If subprocess has more than one user tasks, you can retrieve only those tasks where the execution token flow through. Also the tasks will be ignored in exclusive gateway if the other path doesn’t match.

One way of retrieving all the task details is parsing the entire BPMN using the bpmn-model-api

While parsing bpmn to retrieve subprocess tasks you can try something like this:

ModelElementInstance scope = bpmnModelInstance.get.....(); 
if (scope instanceof SubProcess) {
   SubProcess subProcess = (SubProcess) scope;
   //add condition to ignore if it's an event subprocess
   // TODO: access subProcess element
}

Note that, parsing bpmn model will give you the attributes/properties of the activity only.

1 Like

Thanks.
The first solution looks like more match for my case than the second.
But I have a question :
What the meaning of “Where the execution token flow through” ?
Can you please explan more about that ?

Than you.

I find the doc about the execution at the Camunda documentations
https://docs.camunda.org/manual/7.11/user-guide/process-engine/process-engine-concepts/#executions

from the below example, after executing the service task the value evaluated and been set to variable X=12, then the execution path will be satisfying the condition X>10, so the task b wil be executed and task c will be ignored. Execution token can flow through the StartEvent > Task A > Exclusive Gateway > Task B > Exclusive Gateway > EndEvent.