cancel
Showing results for 
Search instead for 
Did you mean: 

find task id by process instance

goutham_pn
Champ in-the-making
Champ in-the-making

I'm creating a task like this,

ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey(ApplicationConstants.POST_APPROVAL_WORKFLOW_NAME, variablesMap);

I want to assign the owner for this, how can I do it.

If not, is it possible to find taskId from this then I can use taskService.setOwner.

Please help me with this.

1 REPLY 1

gdharley
Elite Collaborator
Elite Collaborator

Ok, obviously you are new to Activiti and workflow in general.
You are not directly creating a task, rather, you are creating a process instance based on the workflow definition ApplicationConstants.POST_APPROVAL_WORKFLOW_NAME.

This process instance may include user tasks which show up over time.

To retrieve all current tasks for a given process instance you can use the TaskService to retrieve the tasks from the process instance ID returned by your start command.

Once you have the process Instance:

List<Task> tasks = taskService.createTaskQuery().processInstanceId(pid).list()

This will return a list of tasks.

More details can be found in the Java API here.

Cheers,
greg

bp3‌