# Get all active process instance ID for assignee

**URL:** <https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260>\
**Category:** Flowable Engine\
**Created:** [November 28, 2017, 9:49am UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260 "2017-11-28T09:49:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitshukla](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@amitshukla](https://forum.flowable.org/u/amitshukla)\
**Post date:** [November 28, 2017, 9:49am UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260/1 "2017-11-28T09:49:32Z")

</div>

Hi,

I want to get all active processInstance IDs for any given assignee. I want to know to which all processes he/she was involved with current process status(currently storing this process progress status in separate table along with process ID).Basically, I want to list user all the requests(processIds) in which he was/is involved with current status.

1. Is there a better approach of storing current status ?
2. How to get active process instance ID for any given assignee so that by using this processinstanceID, I can get all request from our own table.

Please guide.

Thanks,  
Amit Shukla

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [November 28, 2017, 11:55am UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260/2 "2017-11-28T11:55:22Z")

</div>

Hi Amit,

There’s the involvedUser option in the ProcessInstanceQuery, but that also includes the user that started the process and was involved in other tasks. You could also use the TaskQuery and get a list of all active user tasks for a specific assignee and filter the result for the list of process instance ids.  
It depends on what kind of status you are storing. If the status is based on user tasks then this info is also stored in the history tables in Flowable. If not, then your approach works fine.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![amitshukla](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@amitshukla](https://forum.flowable.org/u/amitshukla)\
**Post date:** [November 29, 2017, 5:09am UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260/3 "2017-11-29T05:09:00Z")

</div>

> [@tijs](#):
>
> You could also use the TaskQuery and get a list of all active user tasks for a specific assignee and filter the result for the list of process instance ids.

```
List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).list();
List<String> processIds = new ArrayList<>();
for(Task t : tasks) {
      processIds.add(t.getProcessInstanceId());
}
return processIds;	

```

I am getting processInstanceIds from this. Is this right???

Also I have observed, when a task is completed the task is removed from table ‘ACT\_RU\_TASK’ and new taskID is created with assignee depending on workflow created. The task that was completed is found in table ‘ACT\_HI\_TASKINST’. So I want to get list of processInstanceIds in which assignee was involved which could be found in table ‘ACT\_HI\_TASKINST’. Table ‘ACT\_RU\_TASK’ contains only current running task.

So will the above query return processInstanceIds from table ‘ACT\_HI\_TASKINST’ ???

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [November 29, 2017, 5:21am UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260/4 "2017-11-29T05:21:26Z")

</div>

Hi,

Yes that code is correct, although I would use a Set instead of a List, because there could be multiple tasks for the same process instance.

If you want to do this on the historic task table, because you want to include completed tasks, then you should use the HistoryService and then the HistoricTaskInstanceQuery. The code you included in your post will do a query against ACT\_RU\_TASK.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![amitshukla](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@amitshukla](https://forum.flowable.org/u/amitshukla)\
**Post date:** [November 29, 2017, 5:37am UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260/5 "2017-11-29T05:37:30Z")

</div>

Thanks for quick reply.

> [@tijs](#):
>
> If you want to do this on the historic task table, because you want to include completed tasks, then you should use the HistoryService and then the HistoricTaskInstanceQuery.

I hope you meant this query

`historyService.createHistoricTaskInstanceQuery().taskAssignee(assignee).list();`

This will return tasks assigned to a given assignee from ‘ACT\_HI\_TASKINST’ table as it contains completed tasks as well.

> [@tijs](#):
>
> I would use a Set instead of a List, because there could be multiple tasks for the same process instance

I completely agree there could be multiple tasks assigned to same assignee in one process. In that case this query will return different taskIds with same processIds.

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [November 29, 2017, 3:29pm UTC](https://forum.flowable.org/t/get-all-active-process-instance-id-for-assignee/1260/6 "2017-11-29T15:29:52Z")

</div>

Yes, that’s the correct query.

Best regards,

Tijs
