How to know the state of a task?

When running a query with historicService, I get a list of the tasks for a particular case:

    List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery()

I can find a way to get the state of an HistoricTaskInfo. I know I can filter during the query with finished() or unfinished(), but I really would like a single query an then process the tasks according the state.

A finished task is a task that has endTime set. An unfinished task is a task where the endTime is null.

But automated tasks like httptask dont get recorded on task completion. How do I retrieve historical task info in such cases

@bvedam in order to query for all activities within a BPMN process you would need to use the HistoricActivityInstanceQuery. You can get an instance of it via HistoryService#createHistoricActivityInstanceQuery

Thanks Filip. I haven’t tried the API yet as the Admin Web UI never lists automated tasks in the tasks tab. Will try and follow-up if I have questions.

Thanks Filip for your response. I am using the REST API and don’t have any custom java code. There is this REST API to get historic task instance detail but like I said earlier it is returning only the manual tasks and doesn’t provide any info on the 2 HTTP task. The Admin app has this same problem. In the “Process Engine->Instances” tab, I see only 2 tasks while the diagram shows the manual and HTTP tasks. Any way I can get ALL the tasks executed? Thx

@bvedam if you use the REST API you can get access to all the historic activity instances via the Get historic activity instances endpoint.

Thank you. That is exactly what I was looking for. I was searching by the “task” term, as they were historic task instances. Totally overlooked the section on activity. Thanks again

Hi @filiphr, I am querying historic task instance in a Service Task like this:

    List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery()
                                                                     .processInstanceId( execution.getProcessInstanceId() )

It returns me the details of user task just before it, even though the end date is populated in user task. Does that mean a user task is not counted as finished until it reached the next wait state?

I’m using flowable version 6.4.1

Hey @akki,

I see that you also posted Unfinished HistoricTaskInstance please do not cross post the same question in multiple threads. You will get an answer

1 Like