cancel
Showing results for 
Search instead for 
Did you mean: 

Pause and Resume User Task

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Hello

Is it possible to pause and resume user tasks? We also need to track the time taken betweem pause and resume task.

The user clicks on pause and goes for a break, and he clicks on resume to continue. We need to track how long has he gone for a break.

Thank you
parul
10 REPLIES 10

jbarrez
Star Contributor
Star Contributor
That functionality is not available out of the box.

You can however easily do it yourself, by setting a Date variable when the user clicks a pause/resume button in your app.
When retrieving these variables, you can then compare them to get the time difference.

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
yes, but how can it be linked to a task. Is there a way to get total time between claimimg a task and finishing it?

Thank you
parul

frederikherema1
Star Contributor
Star Contributor
The History contains this kind of information. Currently, you can retrieve the startTime, endTime and duration from a HistoricActivityInstance. Example:


historyService.createHistoricActivityInstanceQuery().processInstanceId(myProcessId).activityType("userTask").activityName("theTask").singleResult();

Make sure the history-level is set to the right value, http://activiti.org/userguide/index.html#historyConfiguration

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
I created some tasks and assigned to users. users completed their tasks. All through coding.
I am not able to see finished tasks through history service using
processEngine.getHistoryService()
.createHistoricActivityInstanceQuery()
   .finished()
   .orderByHistoricActivityInstanceDuration().desc()
   .listPage(0, 10);

This shows the finished tasks from examples but not the tasks which we created through coding.
Where did I go wrong?

Thank you,
parul

frederikherema1
Star Contributor
Star Contributor
Parul,

How did you create the tasks? Were they created by a running processInstance, or did you manually create them (taskService.newTask())?

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Manually created


Task task = taskService.newTask();
task.setName(request.getParameter("taskname"));
taskService.saveTask(task);
String userid = request.getParameter("userid");
if(userid!=null && !userid.equals("null") && !userid.trim().equals(""))
taskService.addCandidateUser(task.getId(),userid );

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Also I see that manually created tasks have no execution ids or process instance ids. Does it mean that manually created tasks cannot have a history?

Thank you,
parul

jbarrez
Star Contributor
Star Contributor
That is something which iscurrently being fixed and will end up in the 5.1 release.

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Hello

For Pause and Resume User Task Implementation, I have a rough idea on how to do it.

1. Extend TaskService interface

interface TaskServiceWithPauseandResume extends TaskService
{
   public void pauseTask(String taskid);
   public void resumeTask(String taskid);
}

2. Implement the above interface in say(TaskServiceWithPauseandResumeImpl)
3. Now when I get TaskService using processEngine.getTaskService(), I have to typecast to get Pause and Resume services.

TaskServiceWithPauseandResume mytaskservice = (TaskServiceWithPauseandResumeImpl)processEngine.getTaskService();

Is this the right way of doing it? Please suggest.

Thank you
parul