cancel
Showing results for 
Search instead for 
Did you mean: 

Pooled vs Assigned tasks

mangar
Star Contributor
Star Contributor
Is there any way to set up an Activiti workflow to, at run time, assigning a task to a user, if there is only ONE user in a list, and assign it to a pool if there is more than one user?

I was looking at the longhand way of using
<potential owners>
  but that still looked like a pool.

can someone point me in the right direction?  Some examples maybe?
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

in such a case you would normally use a task execution listener to encapsulate that logic. I don't think it can be expressed in BPMN XML since the two assignment variants are conceptionally different (even if the group just has one member "now").
See <a href="http://www.activiti.org/userguide/#bpmnUserTaskAssignment">Activiti Guide - User Task Assignment</a> for details.

Regards
Axel

mangar
Star Contributor
Star Contributor
I am also pretty sure it cannot be done in the XML workflow definition.  I will look a the the task execution listener, thank you.

mangar
Star Contributor
Star Contributor
here is the code: 

In my workflow deffinition, I have this task:


      <userTask id="usertask1" name="myOrder" activiti:formKey="jiswf:myOrders">
         <extensionElements>
            <activiti:taskListener event="create" class="org.xxx.TaskAssignerTaskListener"></activiti:taskListener>
         </extensionElements>
      </userTask>


ant the task listener is like this:


   public void notify(DelegateTask task) {
      String[] users = (String[]) task.getVariable("jiswf_toName");
      if(users.length==1) {
         task.setAssignee(users[0]);
      } else {
         task.addCandidateUsers(Arrays.asList(users));
      }
   }


and i send in a String[] when starting the workflow.