AnsweredAssumed Answered

Java backed webscript, retrieving package items by task id throws null pointer exception

Question asked by sihnu on May 22, 2015
Latest reply on May 22, 2015 by sihnu
Hi,

I'm looping through completed workflows. I do tasks search retrieving all the tasks of the workflow instance. I parse the tasks and then try to search all the package items of the task and I get null noderef exception. I can see the nodeRef in log and I have tried to find the node using node browser and it looks like the node doesn't exist. Why does the workflowservice try to search a node that doesn't exist?

Here is my code:

List<WorkflowInstance> instances = this.workflowService.getCompletedWorkflows();
for (WorkflowInstance instance : instances) {
  WorkflowTaskQuery query = new WorkflowTaskQuery();
  query.setActive(false);
  query.setTaskState(null);
  query.setProcessId(instance.getId());
  List<WorkflowTask> tasks = workflowService.queryAllTasks(query);
  WorkflowTask endTask = getEndTask(tasks); // I needed to my own parsing here because when I tried to do the query with custom properties I always got empty list
  if (endTask != null) {
    List<NodeRef> items = this.workflowService.getPackageContents(endTask.getId()); // HERE THE ERROR OCCURS!!!
    …
  }
}


Any help would be greatly appreciated.

Outcomes