# Get task ID when triggering a process

**URL:** <https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030>\
**Category:** Flowable Engine\
**Created:** [October 4, 2017, 9:26pm UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030 "2017-10-04T21:26:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![schaloner](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@schaloner](https://forum.flowable.org/u/schaloner)\
**Post date:** [October 4, 2017, 9:26pm UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/1 "2017-10-04T21:26:07Z")

</div>

Hi,

I’ve just started using Flowable, and have a question on obtaining task IDs when starting a process. Given that I start a process using something like

```
final ProcessInstance process = runtimeService.startProcessInstanceByKey("someProcessName", variables);

```

Is it possible to immediately obtain the task ID(s) associated with this specific instance of the process?

Thanks,  
Steve

---

<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:** [October 5, 2017, 5:17am UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/2 "2017-10-05T05:17:26Z")

</div>

Hi Steve,

Yes that’s possible. In the case when the process task is the first wait state (in fact it means that there is no asynchronous task between process start event and user task), you can query for the tasks of the started process instance with taskService query.

Martin

---

<div class="post-metadata">

**Author:** ![schaloner](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@schaloner](https://forum.flowable.org/u/schaloner)\
**Post date:** [October 5, 2017, 3:40pm UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/3 "2017-10-05T15:40:36Z")

</div>

Hi Martin,

thanks for the help. I’ll code this up and see how it goes. There may be more questions!

Regards,  
Steve

---

<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:** [October 5, 2017, 3:41pm UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/4 "2017-10-05T15:41:37Z")

</div>

Looking forward to them. 🙂

---

<div class="post-metadata">

**Author:** ![shweta](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/shweta/32/360_2.png) [@shweta](https://forum.flowable.org/u/shweta)\
**Post date:** [November 2, 2017, 1:14pm UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/5 "2017-11-02T13:14:22Z")

</div>

Hi Martin,  
I didnt get how we can actually achieve this. Could you elaborate.

TaskService.getTaskFormModel(String taskId)

What to place here for taskID?

---

<div class="post-metadata">

**Author:** ![zhiyin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/zhiyin/32/376_2.png) [@zhiyin](https://forum.flowable.org/u/zhiyin)\
**Post date:** [November 5, 2017, 2:19am UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/6 "2017-11-05T02:19:08Z")

</div>

hi shweta:  
maybe you can try this code:

TaskService().createTaskQuery().processInstanceId(processInstanceId).list();

According to the different starting flow chart design, where the task ID may have a plurality of, or null.

Hint: asynchronous, service node, concurrent process

---

<div class="post-metadata">

**Author:** ![shweta](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/shweta/32/360_2.png) [@shweta](https://forum.flowable.org/u/shweta)\
**Post date:** [November 6, 2017, 4:59am UTC](https://forum.flowable.org/t/get-task-id-when-triggering-a-process/1030/7 "2017-11-06T04:59:06Z")

</div>

Hi Zhiyin,  
Thanks for the solution. Worked for me 🙂  
Cheers

Thanks and regards  
Shweta
