I have a process which enables users to make comments to tasks during various steps in the workflow.
At some point, I need to be able to view all the comments made. This 'point' is also within a task. What I have now is, assuming that taskId is the task in which the process finds itself when it needs to view the history comments:
String executionId = processEngine.getTaskService().getTask(taskId).getExecutionId();
Execution execution = processEngine.getExecutionService().findExecutionById(executionId);
String processInstanceId = execution.getProcessInstance().getId();
List<HistoryDetail> history = processEngine.getHistoryService().createHistoryDetailQuery()
This always returns an empty array, even though there are definitely comments made to previous steps in the workflow. I can verify that by examining the database. Trace code shows the processInstanceId to be what I expect it to be, but for some reason the History comments can't be retrieved.
What's the correct way of doing it? Ie, getting all comments that was made on all tasks that were in the same process instance of a given task?
Sidenote, I made the comments in custom java code, but the userid_ field in the table jbpm4_hist_detail remaind empty. Should I explictly set a userid?