MultiInstance CallActivity - How to distinguish user tasks?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2014 12:46 PM
Hi, I have defined a parallel MultiInstance Call Activiti(Sub-Process, cardinality = 2) which contains UserTasks. When I complete the user tasks, how to distinguish user task created by first instance verses second one, because both the user tasks will have the same name/id.
If I need to depend on the loop variables, please let me know whats the best way to do that because in the sub-process I have more than one user task.
Thanks for your help
If I need to depend on the loop variables, please let me know whats the best way to do that because in the sub-process I have more than one user task.
Thanks for your help
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2014 03:42 AM
You could, for example, use a task-create listener to set a task-local variable on the task that's being created, based on the value of the loop counter. Or, alternatively, use an expression that contains the loop counter for "name" or "documentation" of the task.
Also, the execution-id of the tasks will be different. If you use that value, you can identify what execution it belongs to.
Also, the execution-id of the tasks will be different. If you use that value, you can identify what execution it belongs to.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2014 08:07 AM
Thanks for your quick response. When I use the loopCounter in the task's name, like "name${loopCounter}", it says unknown property used in expression.
I have not tried the listener yet, but wondering the loopCounter will available in the listener. I will try the listener too.
I have not tried the listener yet, but wondering the loopCounter will available in the listener. I will try the listener too.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2014 12:21 PM
I created a taskListener, org.activiti.engine.delegate.TaskListener, and trying to get the loopCounter following way and the value is null. How to get the loopCounter in the listener?
public void notify(DelegateTask delegateTask) {
String loopCounter = String.valueOf(delegateTask.getVariable("loopCounter"));
log.info("loopCounter : " + loopCounter);
}
Thanks!
public void notify(DelegateTask delegateTask) {
String loopCounter = String.valueOf(delegateTask.getVariable("loopCounter"));
log.info("loopCounter : " + loopCounter);
}
Thanks!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2014 03:06 PM
Hi,
be aware the first loop counter is null.
Regards
Martin
public class ActivityStartListener implements ExecutionListener {
public void notify(DelegateExecution execution) throws Exception {
Integer loopCounter = (Integer) execution.getVariable("loopCounter");
if (loopCounter == null) {
loopCounter = 0;
}
execution.setVariable("executionListenerCounter", ++loopCounter);
}
}
be aware the first loop counter is null.
Regards
Martin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2014 02:34 AM
that's strange, the variable should be available AFAIK. Try the listener-approach and report back if not working…
