How can I get next user task id when completed an user task?

Hi, is there any way that I can get new-generated user taskId when I call runtimeService.startProcessInstanceById or taskService.completeTask?

[type or paste code here](https://docs.camunda.io/docs/apis-tools/tasklist-api-rest/specifications/search-tasks/)

Doesn’t this help?

This seems still like search tasks in another request. I’m trying to make taskService.completeTask return new generated task…

As far as I know, this isn’t possible for c7 - neither when calling runtimeService nor when calling taskService.

At least I’ve never seen anything like this before, and from a technical and model perspective, i could understand that there are reasons why this isn’t supported (apart from the fact that, under certain circumstances, not everything happens synchronously/in a single transaction - and therefore its not guaranteed that you directly have this information).

With one example: Imagine there’s a wait state, like a message-receive event, after your process-start-event (that you trigger with runtimeService). Which task should it return if there’s none yet?

Or with another example: Suppose you complete „User Task 1“ with taskService. Which task should it return then - if there are multiple follow-up tasks?

So, to wrap it up, I think the only way to get the next task is as @Domingos_Dias suggested - to write something like:

    fun doSomething(input: Input) {
        runtimeService.startProcessInstanceByMessage(…)
        return taskService.createTaskQuery()…
    }