cancel
Showing results for 
Search instead for 
Did you mean: 

Do you have support to trace history when changing assignee or candidate?

holysoul
Champ in-the-making
Champ in-the-making
Well, hi all.
As my topic tittle, I wonder if Activiti support us tracing history when changing assignee or candidate? Or I have to have separate logging when do those actions?
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Claim event is recorded

public void recordTaskClaim(String taskId) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
      HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
      if (historicTaskInstance != null) {
        historicTaskInstance.setClaimTime( ClockUtil.getCurrentTime());
      }
    }   
  }

Regards
Martin

holysoul
Champ in-the-making
Champ in-the-making
Thanks. It is helpful for me. However, I think it is time for someone claimed task, it does not really relate to time I change assignee/group, isn't it?
I have one more question. I use this method to change candidate group, is it okay?
<code>
   processEngine.getTaskService().addCandidateGroup(taskId, newGroupID);
   processEngine.getTaskService().deleteCandidateGroup(taskId, oldGroup);
</code>
If using this way, how can I track history by using Activiti API?
And when I set assignee using "processEngine.getTaskService().setAssignee(taskId, userId)" for someone, is he/her set up default  claimTime?

trademak
Star Contributor
Star Contributor
You can track the history of identity links with the HistoryService.
So setAssignee doesn't set the claim time, that's only done when you execute the claim method.

Best regards,

holysoul
Champ in-the-making
Champ in-the-making
I try to trace the history of changing assignee. Here are my steps:
- start process instance
- change assignee of one task : for example
<code>
processEngine.getTaskService().setAssignee("69", "kermit");
processEngine.getTaskService().claim("69", "kermit");
</code>
- then change again
<code>
processEngine.getTaskService().setAssignee("69", "gonzo");
processEngine.getTaskService().claim("69", "gonzo");
</code>
- try to trace identifyLink
<code>
List<HistoricTaskInstance> listTask = null;
listTask = processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().list();
for (HistoricTaskInstance historicTaskInstance : listTask) {
       List<HistoricIdentityLink> identityLinks = processEngine.getHistoryService().getHistoricIdentityLinksForTask(historicTaskInstance.getId());
for(HistoricIdentityLink historicIdentityLink:identityLinks){
              System.out.println(historicTaskInstance.getId()+"/"+historicTaskInstance.getAssignee()+"/"+historicIdentityLink.getUserId()+"/"+historicTaskInstance.getClaimTime()+"/"+historicTaskInstance.getStartTime());
}
}
</code>

I though that the identityLinks would record the change from gonzo–> kermit–> gonzo. However, it only recorded the newest change: information of the gonzo. So using this way, I can not trace the changing assignee history. Do I mistake somewhere?

trademak
Star Contributor
Star Contributor
Ah ok now I understand your question. No that's not being stored in the Activiti tables currently. Of course it's possible to maintain an audit list yourself using the Task listeners. We are thinking about adding an additional history table with exactly this information.

Best regards,

holysoul
Champ in-the-making
Champ in-the-making
Thank trademak. I'm waiting for your great Activiti Smiley Happy