cancel
Showing results for 
Search instead for 
Did you mean: 

multi instance collection on xml

dthknt
Champ on-the-rise
Champ on-the-rise
I'm trying to create a task with a colection for multi insance approvals over some groups. It's an readonly list, so it makes more sense to write it directly on the bpmn xml. I tryed this:


<userTask id="aprovarPCMC" name="Aprovar Plano de Curso e Matriz Curricular" activiti:candidateGroups="#{group}">
<multiInstanceLoopCharacteristics isSequential="true"
             activiti:collection="${java.util.Arrays.asList(&quot;NDE&quot;,&quot;direcao&quot;)}"
             activiti:elementVariable="group">
</multiInstanceLoopCharacteristics>


Where the expression would resolve to:


Arrays.asList("NDE","direcao")


But it gives me an error that says "java could not be resolved".
The User Guide only has examples for getting the list from variable or service. I want it on the xml.
Is it possible ?
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
No, i don't think so. That would work on a script task, but not in a JUEL expression. Maybe use a script execution listener just before the multi instance that sets it?

dthknt
Champ on-the-rise
Champ on-the-rise
Isn't there an easier solution ?
Some tag where i would set the list like <sourceList>group1,group2,group3</sourceList> ?

If there isn't I'll just create a bean for that.

Also could you provide an example with ScriptTask ?
I'm kind of new at Activiti and also the only one here messing with it !

Thanks

dthknt
Champ on-the-rise
Champ on-the-rise
I solved it with Java service task.
For future reference:
<code>
<serviceTask id="generateList" name="name"
             activiti:class="br.com.app.servicetask.ClassName">
         <extensionElements>
         <activiti:field name="values" stringValue="group1,group2" />
      </extensionElements>
     </serviceTask>
</code>

The class just splits the field values and sets it to an variable

jbarrez
Star Contributor
Star Contributor
A sriptTask would effectively do the same: execution.setVariable('collection', java.util.Arrays.asList('a', 'b'));