Getting the task id when starting a process

Hello,

When starting a process, I noticed we have only the process id.

How can we get the task id at that initial stage ?

Thanks.

On success of process creation, you can query for the tasks using Rest API or Native sql query or through Java API

When starting a process in the custom web app, how can you attach a document ?
At that time we do not have a task id generated.

Thanks.