# Get Currently Active Process Task

**URL:** <https://forum.flowable.org/t/get-currently-active-process-task/9117>\
**Category:** Flowable Engine\
**Created:** [March 17, 2022, 4:48am UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117 "2022-03-17T04:48:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Shane](https://forum.flowable.org/u/Shane)\
**Post date:** [March 17, 2022, 4:48am UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/1 "2022-03-17T04:48:51Z")

</div>

I have a few questions to do with tasks…

1. Using code (not REST API) what is the best way, with having a process id to get the currently active task (no parallel tasks yet) in the the active process?

2. I noticed the TaskService API had many methods that took taskId as a parameter but i’m not sure how to get a taskId for a task in an active process.

3. Is an instance of a Task called an Activity? If not, what is an Activity?

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [March 17, 2022, 9:47am UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/2 "2022-03-17T09:47:08Z")

</div>

> [@Shane](#):
>
> Using code (not REST API) what is the best way, with having a process id to get the currently active task (no parallel tasks yet) in the the active process?

runtimeService execution query. execution.activityId

> [@Shane](#):
>
> I noticed the TaskService API had many methods that took taskId as a parameter but i’m not sure how to get a taskId for a task in an active process.

`taskService.createTaskQuery().processInstanceId('').list()` for list of tasks for given process. (If you are searching by included user it is also possible)

> [@Shane](#):
>
> Is an instance of a Task called an Activity? If not, what is an Activity?

No, activity can be userTask, or any other activity in the process.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![Shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Shane](https://forum.flowable.org/u/Shane)\
**Post date:** [March 17, 2022, 4:43pm UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/3 "2022-03-17T16:43:39Z")

</div>

thanks for the prompt response!

i am confused then, i can see where taskService.createTaskQuery().processInstanceId(processId).list() would return a list of tasks because taskService is task centric.

but, in my code, runtimeService.createExecutionQuery().processInstanceId(processId).count() == 2 which surprises me.

seems like if i kick off a new instance of a workflow and get a single processId from doing that then that processId would return only one execution since a process instance is the same as an execution…

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

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [March 17, 2022, 5:16pm UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/4 "2022-03-17T17:16:22Z")

</div>

`processInstance` is execution too. use `onlyChildExecutions` for `executionQuery`

---

<div class="post-metadata">

**Author:** ![Shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Shane](https://forum.flowable.org/u/Shane)\
**Post date:** [March 17, 2022, 7:14pm UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/5 "2022-03-17T19:14:06Z")

</div>

hopefully i can better explain what i need so not to take up more of your time on this subject… the scenario is we are creating a prototype to convince our boss to go with Flowable and we have one part where an independent microservice must check where in our workflow (i.e. which activity) is currently waiting for an outside reply. the microservice has access to process ids.

so i was hoping there was a simple…  
Activity currActivity = someFlowableServiceObj.getProcessIntanceById(someProcId).getCurrentOpenActivity()

that’s what i was trying to find out in my first question.

thanks!

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [March 18, 2022, 7:02am UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/6 "2022-03-18T07:02:29Z")

</div>

```auto
// in your case only one execution is selected
        List<Execution> executions = runtimeService.createExecutionQuery().onlyChildExecutions().processInstanceId(processInstance.getId()).list();
// activityId is id from the modeler. Can be any wait state (user task, async service task, receive task.....)
        List<String> activityIds = executions.stream().map(Execution::getActivityId).collect(Collectors.toList());

```

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![Shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Shane](https://forum.flowable.org/u/Shane)\
**Post date:** [March 18, 2022, 7:15pm UTC](https://forum.flowable.org/t/get-currently-active-process-task/9117/7 "2022-03-18T19:15:11Z")

</div>

okay.  
thanks for the info!
