Get task ID when triggering a process

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

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

Hi Martin,

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

Regards,
Steve

Looking forward to them. :slight_smile:

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

TaskService.getTaskFormModel(String taskId)

What to place here for taskID?

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

Hi Zhiyin,
Thanks for the solution. Worked for me :slight_smile:
Cheers

Thanks and regards
Shweta