cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get historicTaskInstance By unfinished filter

smartxiaofish
Champ in-the-making
Champ in-the-making
Hi~
i have some tasks completed and deleted before completed.
and i tried  historySrv.createHistoricTaskInstanceQuery().finshed() and unfinished().

here is the test code

      Task task = taskSrv.newTask();
      task.setName("test execution");
      task.setOwner(user1.getId());
      task.setAssignee(user2.getId());
      taskSrv.saveTask(task);
      
      // delete it
      taskSrv.deleteTask(task.getId(), "ownerDelete");
      
      // check deletion by assignee
      List<HistoricTaskInstance> hisTaskListByAssignee = historySrv.createHistoricTaskInstanceQuery()
                                       .taskAssignee(user2.getId()).list();
      assertEquals(1, hisTaskListByAssignee.size()); // passed
      assertEquals("ownerDelete", hisTaskListByAssignee.get(0).getDeleteReason());
      
      
      // check deletion by owner
      List<HistoricTaskInstance> hisTaskListByOwner = historySrv.createHistoricTaskInstanceQuery()
                                       .taskOwner(user1.getId()).unfinished().list();
      assertEquals(1, hisTaskListByOwner.size()); // failed and hisTaskListByOwner.size() is 0
      assertEquals("ownerDelete", hisTaskListByOwner.get(0).getDeleteReason());


it seems that finished task doesn't mean completed task.
so what does finished tasks and unfinished tasks mean in historicTaskInstance ?
and is there any way to get tasks completed and deleted before completed in HistoricTaskInstanceQuery?

appreciate for any reply.
2 REPLIES 2

balsarori
Champ on-the-rise
Champ on-the-rise
No finished doesn't mean completed. A finished task is a task that is no longer active, either has been completed or deleted. Finished tasks mostly have delete reason set to either 'completed' or 'deleted' (or whatever delete reason that was specified when deleting the task).

So, it's not possible to delete then complete a task, since both result to task being inactive (finished), therefore can not be modified and will not be returned when using HistoricTaskInstanceQuery.unfinished()

To get tasks that were deleted with deleteReason set to 'ownerDelete', use the following

[java]
// check finished tasks that were deleted by owner
List<HistoricTaskInstance> hisTaskListByOwner = historySrv.createHistoricTaskInstanceQuery().taskOwner(user1.getId())
.finished().taskDeleteReason("ownerDelete").list();
assertEquals(1, hisTaskListByOwner.size());
assertEquals("ownerDelete", hisTaskListByOwner.get(0).getDeleteReason());

[/java]

smartxiaofish
Champ in-the-making
Champ in-the-making
thanks~ it's clear now 🙂
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.