cancel
Showing results for 
Search instead for 
Did you mean: 

MultiInstance CallActivity - How to distinguish user tasks?

kusam_activiti
Champ in-the-making
Champ in-the-making
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
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
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.

kusam_activiti
Champ in-the-making
Champ in-the-making
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.





kusam_activiti
Champ in-the-making
Champ in-the-making
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!

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,


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

frederikherema1
Star Contributor
Star Contributor
that's strange, the variable should be available AFAIK. Try the listener-approach and report back if not working…
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.