02-28-2017 11:28 PM
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.
03-01-2017 08:50 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.