# Get all the tasks (including from subprocesses) with ProcessInstanceId of the main process

**URL:** <https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969>\
**Category:** Flowable Engine\
**Created:** [November 27, 2019, 7:31pm UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969 "2019-11-27T19:31:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FJM](https://avatars.discourse-cdn.com/v4/letter/f/6f9a4e/32.png) [@FJM](https://forum.flowable.org/u/FJM)\
**Post date:** [November 27, 2019, 7:31pm UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/1 "2019-11-27T19:31:35Z")

</div>

Hi everybody,

Is there any way of getting all the active user tasks of a process and it’s subprocesses, providing only the main ProcessInstanceId?

I got this main process, that only has a call to a subprocess:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/3/38afd7dbdeffb98f7aba0ecebedb0517e415851a.png)  
And the subprocess is:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/3/3f162d0ea6f65d48c6a38017097d798411d8c82e.png)

I’ve started with sucess the main process:  
String processInstanceId = processEngineMap.getProcessEngines().get(TENANT).getRuntimeService()  
.startProcessInstanceByKeyAndTenantId(key, TENANT).getId();

The query says it is stop at the first task, of the subprocess. But I only now this when I query all the running tasks:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/e/ee216cc4cb569fa17f072efbb5d6b5fe43a019e8.png)

If I try to use the main Process InstanceId I’m not see any method that retrieves all the tasks of the parent and sons:  
processEngineMap.getProcessEngines().get(TENANT).getTaskService().createTaskQuery().processInstanceId(processInstanceId).processInstanceIdWithChildren(processInstanceId).list()

or  
processEngineMap.getProcessEngines().get(TENANT).getTaskService().createTaskQuery().processInstanceIdWithChildren(processInstanceId).list()

Wasn’t supposed processInstanceIdWithChildren to retrieve all tasks?

Or I have to go the big way around getting and iterating to know all the processes and their subprocesses, and then querying the tasks with all that IDs (with the getRuntimeService().createProcessInstanceQuery().superProcessInstanceId(processId).list()) ?

Thanks for your attention,  
Filipe

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [December 4, 2019, 6:01pm UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/2 "2019-12-04T18:01:50Z")

</div>

> [@FJM](#):
>
> Wasn’t supposed processInstanceIdWithChildren to retrieve all tasks?

Yes, but you will need to have entity links enabled (set enableEntityLinks to true on your process engine configuration).

---

<div class="post-metadata">

**Author:** ![tshaug](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tshaug](https://forum.flowable.org/u/tshaug)\
**Post date:** [March 31, 2020, 2:40pm UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/3 "2020-03-31T14:40:16Z")

</div>

Hi Joram,

sorry for pulling out this old topic.  
I try to set this property in a Spring Boot 2 application. I have not found how to do that…  
I am using flowable 6.5.0 and have also not found this property in the flowable documentation (so far).  
I tried:  
flowable.process.enableEntityLinks=true

Can you give me an advice.

Thank you very much  
Thomas

---

<div class="post-metadata">

**Author:** ![tshaug](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tshaug](https://forum.flowable.org/u/tshaug)\
**Post date:** [March 31, 2020, 8:05pm UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/4 "2020-03-31T20:05:52Z")

</div>

HI Joram,

Ok, I figured out myself:  
I defined the following class:

@Configuration  
public class FlowableEnableEntityLinkConfiguration implements EngineConfigurationConfigurer {

public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {  
processEngineConfiguration.setEnableEntityLinks( **true** );  
}

@Bean  
public FlowableEnableEntityLinkConfiguration getMyConfig() {  
return this;  
}  
}

Is that ok, or are there other means to do this?

Thanks  
Thomas

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [April 13, 2020, 11:29am UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/5 "2020-04-13T11:29:21Z")

</div>

> [@tshaug](#):
>
> Is that ok, or are there other means to do this?

That’s the way indeed when there’s no property exposed in the Spring Boot configuration.

---

<div class="post-metadata">

**Author:** ![tshaug](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tshaug](https://forum.flowable.org/u/tshaug)\
**Post date:** [April 14, 2020, 9:03am UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/6 "2020-04-14T09:03:23Z")

</div>

Hi Joram,

thanks for confirming!

Cheers  
Thomas

---

<div class="post-metadata">

**Author:** ![FJM](https://avatars.discourse-cdn.com/v4/letter/f/6f9a4e/32.png) [@FJM](https://forum.flowable.org/u/FJM)\
**Post date:** [April 23, 2020, 3:42pm UTC](https://forum.flowable.org/t/get-all-the-tasks-including-from-subprocesses-with-processinstanceid-of-the-main-process/4969/7 "2020-04-23T15:42:08Z")

</div>

Hello Joram,

Sorry for my (late) response, but I was around other projects and only now is the time that I’m returning to flowable.  
I’ve tried your solution turning on the enableEntityLinks and the processInstanceIdWithChildren now returns the subprocess tasks.

Thanks so much!
