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.


  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 :


@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

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

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.

   ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();

        RuntimeService runtimeService = processEngine.getRuntimeService();
        ProcessInstance adressenEroffnenProcess = runtimeService.startProcessInstanceByKey(ProcessConstants.ID,

        String processDefinitionId = repositoryService.createProcessDefinitionQuery()
        ModelElementInstance documentElement = repositoryService.getBpmnModelInstance(processDefinitionId).getDocumentElement();

        if (documentElement instanceof SubProcess) {
            SubProcess subProcess = (SubProcess) documentElement;
            // TODO: access subProcess element

You can do like that too. :slight_smile:

In my case i need to list all the users tasks names related to the Bpmn service diagram
not for the active tasks or ended tasks - but to list all the tasks names so we can explain for the current loged in user to see what his responsibilities on this service based on his candidate group

so i did use this API - > {{camunda-url_server}}/process-definition/key/slum_deed_services/xml

then parse the XMl to C# object .