Getting all Tasks by processinstanceId - including those in subprocesses

Hello,

let’s assume that i have a given processinstance Id. Now i want to receive all tasks in that process instance, but i also want to receive the tasks in the subprocesses’ instances and in the subsubprocesses instances etc… In fact that i don’t know the number of nested subprocesses - how can i get all of these tasks? What would be an elegant solution, to archieve this? Something like:

public Task getAllTasks(String processInstanceId){
...
}

Many thanks in advance!

Best regards
Andy

Hey Andy,

you could use the businessKey to archive this.

Greets Chris

Hi Chris,

thank you for your quick reply. Can you specify, what you are meaning? I have never worked with business keys. I know, that the business key is a unique identifier like processinstanceId, but more meaningful for business purposes. Do you mean, that i have to give a business key when i’am starting a parent process instance? And when the engine is calling a subprocess it will forward the parent instance’s businessKey through the child processinstance?

And then i have just to query for tasks with the specified business key. Is that right?

Thank you :slight_smile:
Greets Andy

Hey Andy,

Do you mean, that i have to give a business key when i’am starting a parent process instance? And when the engine is calling a subprocess it will forward the parent instance’s businessKey through the child processinstance?

Exactly this is what I meant. I think we can improve the documentation about that topic.

Greets
Chris