cancel
Showing results for 
Search instead for 
Did you mean: 

Multi instance

yz250
Champ in-the-making
Champ in-the-making
Hi, I am new to Activiti and I have just start learning how to design workflows.
I have a question, in a workflow there is an user task where there is a candidate group ("admin"), the problem is that I want assigne the task to all users in this group, I don' t want just candidate the whole group, how can I do it? Should I use the multi instance option? If yes how can I use it?
I' ve tryed to create a collection of usernames but it doesn' t work.

Thanks all, Ivan.
13 REPLIES 13

yz250
Champ in-the-making
Champ in-the-making
yes it is called but I don' t know if I am doing it in the right way, in the designer I click on the user task, then listeners and then "new", there I choose my class.

yz250
Champ in-the-making
Champ in-the-making
Ok, now the process has found the java class, but it always shows the exception "variable nameList is not a collection", how can I fix it?

Thanks, Ivan

yz250
Champ in-the-making
Champ in-the-making
Yes! I' ve sort it out! I forgot this line in the java class: "execution.setVariableLocal("nameList", nameList);" now it works perfectly!

cantwait
Champ in-the-making
Champ in-the-making
Hey man I have the same issue and I can't make it work… this is my configuration…

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="Process-test" name="process-test">
    <documentation>Place documentation for the 'process-test' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="sayHelloTask" name="Hello Activiti">
      <extensionElements>
        <activiti:taskListener event="create" class="com.odebrecht.activiti.assigment.MultiInstanceAssigment"></activiti:taskListener>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopDataInputRef>usuarios</loopDataInputRef>
        <inputDataItem name="${assignee}"></inputDataItem>
      </multiInstanceLoopCharacteristics>
    </userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="sayHelloTask"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" name="" sourceRef="sayHelloTask" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Process-test">
    <bpmndi:BPMNPlane bpmnElement="Process-test" id="BPMNPlane_Process-test">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="150" y="120"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sayHelloTask" id="BPMNShape_sayHelloTask">
        <omgdc:Bounds height="55" width="105" x="290" y="110"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="500" y="120"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="185" y="137"></omgdi:waypoint>
        <omgdi:waypoint x="290" y="137"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="395" y="137"></omgdi:waypoint>
        <omgdi:waypoint x="500" y="137"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


package com.odebrecht.activiti.assigment;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

public class MultiInstanceAssigment implements TaskListener{

@Override
public void notify(DelegateTask dt) {
  ArrayList<String> usuarios = new ArrayList<String>();
  usuarios.add("rcadenas");
  usuarios.add("carlos");
  usuarios.add("yonatha");
  Collections.sort(usuarios);
  dt.setVariableLocal("usuarios", usuarios);
 
}

}

I really appreciate you can give me a hand with this…

Thanks in advance.