cancel
Showing results for 
Search instead for 
Did you mean: 

History by User Task Claim time

ruedesilva
Champ in-the-making
Champ in-the-making
Hi,

The project that we are working on requires that the system track how long a user spends on a task. This has to be starting from when a user claimed the task (not when the task started). Currently I do not see this in the DB or any mechanism to handle this. The reason for this is that the company wishes to monitor the performance of the users (how long they spend from claiming a task and completing it). Is there a way to handle this and store the information in the history DB tables? Any examples would be great.

thanks,
Rue
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
Hi,

You could use an task-listener for this. You define the handler to the tasks that need to be monitored, triggering on the event "assignement". In the assignement-handler code, you can (for example) add a local variable to the task (delegateTask.setVariableLocal("claimTime", Calendar.getInstance().getTime()). If you set the histroy-level high enough, task-variables are stored in the history and can be queried for. With some code (or custom query), I guess you can calculate the duration.

see http://activiti.org/userguide/index.html#taskListeners

jbarrez
Star Contributor
Star Contributor
No, that information is not availble in the database at this point, you'll need to add your own variable to track this time.

ruedesilva
Champ in-the-making
Champ in-the-making
Thanks for the information. I thought the Assignment event happens prior to the 'create' event so that the setting the variable in an task listner would not have the correct time? i.e Does the assignment event happen again when a user claims a task or a manager delegates the task to a user? Or is it just a one time reference when the task gets created?

thanks,
Rue

frederikherema1
Star Contributor
Star Contributor
If the activiti:assignee (or BPMN 2.0 humanperformer counterpart) is used, the assignement-event is fired RIGHT before the create event. In this case, it's the same as the create time, so you can just use that time, no? If assignee is null at that time, you know that the task is created unclaimed.

When assignement is set later (using service call for example), you can check if your task-variables already contain a "claim" date from prior assignements (or assignement when task was created). So yes, each assignment causes an event to be thrown.

dbrucegrant
Champ in-the-making
Champ in-the-making
claim_time_ is now a column in the act_hi_taskinst table. Is there a way (in 5.16.3) to access this value through a query OR do I still have to track my own instance of date claimed in a local variable instance?

Thanks,
Bruce.

jbarrez
Star Contributor
Star Contributor
No, it seems that the query doesn't support claim time at the moment.

Cheesy answer: always welcoming pull requests 😉

alin
Champ in-the-making
Champ in-the-making
Could you create your own createNativeTaskQuery() to access the claim time?

trademak
Star Contributor
Star Contributor
Sure that's possible. You can use the NativeHistoricTaskInstanceQuery. But we should add it to the default API as well.

Best regards,