Get Previous Task Information

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2012 01:39 AM
Hi,
How can I get previous task's Id or Information on a task? (by a execution listener, etc.)
Thanks
How can I get previous task's Id or Information on a task? (by a execution listener, etc.)
Thanks
Labels:
- Labels:
-
Archive
7 REPLIES 7

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2012 04:15 AM
Hi, can you elaborate on what exactly you are looking for? You might be looking for the HistoryService.
Cheers,
Nils
Cheers,
Nils

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2012 05:54 AM
Users want to see who completed the previous task.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2012 10:54 AM
Hi,
As Nils said, this can be done via the HistoryService.
Just look in the Javadoc for more details.
Best regards,
As Nils said, this can be done via the HistoryService.
Just look in the Javadoc for more details.
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2012 12:04 PM
Hi,
I'll try it with HistoryService.
Also, how would history service behave in these 2 scenarios.
1. a multi instance task as a first step, and a task as a second step
2. two tasks joined at a paralel gateway as a first step, and a task as a second step
What would be the previous task in these cases. There are not only one previous task in these cases.
Thanks
I'll try it with HistoryService.
Also, how would history service behave in these 2 scenarios.
1. a multi instance task as a first step, and a task as a second step
2. two tasks joined at a paralel gateway as a first step, and a task as a second step
What would be the previous task in these cases. There are not only one previous task in these cases.
Thanks

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2012 03:18 AM
I added a sample diagram for the second situation.
Which one would be the previous task at User Task 3 according to the historyService
Which one would be the previous task at User Task 3 according to the historyService
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2012 10:59 AM
i think u need to give the HistoryService a hint on what could be the previous task connected to the task where u want to get the information, because a process instance can have many execution paths which do not nessessarily lead to your user task 3.
i use the following to get the task which was cancelled using a timer boundary listener when the sequence flow is taken via a execution listener on the sequence flow:
The task to which the boundary timer is attached to is 'usertask2' and for this i want to get the task instance of the running process instance.
In your case u will need to give all your task ids (usertask1, usertask2, …) to the executionListener expression and within the execution listener u can use the history service to get their task end time with task.getEndTime() and decide which one u want to work with, e.g. by putting all task instances in a list and use a comparator based on the end date to sort them to your needs…
hth
i use the following to get the task which was cancelled using a timer boundary listener when the sequence flow is taken via a execution listener on the sequence flow:
@Named
@Stateless
public class EscalationListener {
@Inject
HistoryService historyService;
public void escalate(DelegateExecution execution, String otherTaskId)
throws Exception {
HistoricTaskInstance task = historyService
.createHistoricTaskInstanceQuery()
.processInstanceId(execution.getProcessInstanceId()).
.taskDefinitionKey(otherTaskId).singleResult();
// do some stuff with the task
}
}
<sequenceFlow id="flow13" name="" sourceRef="boundarytimer1" targetRef="servicetask2">
<extensionElements>
<activiti:executionListener event="take" expression="#{escalationListener.escalate(execution, 'usertask2')}"></activiti:executionListener>
</extensionElements>
</sequenceFlow>
The task to which the boundary timer is attached to is 'usertask2' and for this i want to get the task instance of the running process instance.
In your case u will need to give all your task ids (usertask1, usertask2, …) to the executionListener expression and within the execution listener u can use the history service to get their task end time with task.getEndTime() and decide which one u want to work with, e.g. by putting all task instances in a list and use a comparator based on the end date to sort them to your needs…
hth

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2012 12:01 AM
Thank you very much for answers.
