I need to fetch a list of all process instances of a certain process that started before a certain date.
I tried using the runtimeservice:
runtimeService.createProcessInstanceQuery()
.processDefinitionKey(key)
.startedBefore(startDate)
.list();
However, this only gives me the actice process instances. I need the completed instances as well. So I tried using the historyservice:
historyService.createHistoricTaskInstanceQuery()
.processDefinitionKey(key)
.list();
But I couldn’t find a way to specify a startedBefore option. Maybe use the taskCreatedBefore? But that gives me task instances, which I could then group by process instance id. This is possible, but not practical. Is there a better way?