If I have a User Task Instance Id, how do I get the Process Instance Id?

How do I get the Process Instance Id, in java, with as little queries as possible, better with one Process Instance Query, having a User Task Instance Id string?

Update: I have a Task Id that I can get a Task object with the Task Query. I want to avoid extra query for a Task object to get the execution Id.

I need to get process variables of the process instance this task is in.

Hi @fedd,

You can try runtimeService.createProcessInstanceQuery().activityIdIn("userTask");

Best regards,
Yana

1 Like

Do you mean “userTask” is the user task instance id? This is a uuid in my case, and I’ve tried it first hand. It didn’t work :frowning:

I have updated the question. Sorry for my terminology.

Update. Resolved by now with Yana’s advice.

I also want to get the process_instance_id having a task_instance_id. With task_instance_id I mean a value like 1ba18eb5-19f4-11ec-8a8a-00059a3c7a00.

The runtimeService.createProcessInstanceQuery().activityIdIn("userTask"); requires the name of the task, not its instance id.

Any idea?