cancel
Showing results for 
Search instead for 
Did you mean: 

'multi-instance' does not work

othmann
Champ in-the-making
Champ in-the-making
Hi,

  I'm trying to have a mail task repeated several times, in order to send many mails in a loop.

  Here is the BPMN task description :

    <serviceTask id="mailtask1" name="Mail" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to" expression="${invites[loopCounter]}"></activiti:field>
        <activiti:field name="from" expression="xxxxxxxxxxxxxxx"></activiti:field>
        <activiti:field name="subject" expression="XXXXXXXXXXXXXXXX"></activiti:field>
        <activiti:field name="html">
          <activiti:expression><![CDATA[
                    XXXXXXX
           !]]></activiti:expression>
        </activiti:field>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
    </serviceTask>

  In this case, the "loopCounter" variable seems not to be known :

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'loopCounter'

  I've tried the "collection" and "elementVariable" way of doing (which is in fact what I really need), but the variable I chose as "elementVariable" is not known either as a local variable in the process.

   Any help about this would be really appreciated.

  Othman

  PS : It is also very annoying that the Eclipse Designer removes the "multiInstanceLoopCharacteristics" node when we update the process diagram visually. This, however, seems normal.
16 REPLIES 16

othmann
Champ in-the-making
Champ in-the-making
Yes, The previous test works now with the trunk code. Thanks !

However, the mail task still ignores any "multiInstanceLoopCharacteristics" node. For example, if we try this process as a test :

<process id="testMultiMailProcess" name="Processus de test">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:type="mail">
     <extensionElements>
        <activiti:field name="to" expression="xxxxxx@xxxx.com"></activiti:field>
        <activiti:field name="from" expression="xxxxxx@xxxx.com"></activiti:field>
        <activiti:field name="subject" expression="Subject"></activiti:field>
        <activiti:field name="html">
          <activiti:expression><![CDATA[Hello !]]></activiti:expression>
        </activiti:field>
      </extensionElements>
    <multiInstanceLoopCharacteristics isSequential="false">
      <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
    </serviceTask>
    <sequenceFlow id="flow2" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
  </process>

We only receive one mail. Why ? Isn't it in fact a delegate serviceTask ?

othmann
Champ in-the-making
Champ in-the-making
Ok, I tried anything to make it work with no success. I added a comment on the JIRA issue about this : http://jira.codehaus.org/browse/ACT-764

jbarrez
Star Contributor
Star Contributor
I had it fixed a while ago, but forgot to commit it. I've done that yesterday evening.

Could you recheck? Oh yeah, thanks fot the ping 😉

bozon
Champ in-the-making
Champ in-the-making
Does the issue http://jira.codehaus.org/browse/ACT-764 fix any kind of loops for service task including loop over collection elements with 'loopDataInputRef' and 'inputDataItem'?

jbarrez
Star Contributor
Star Contributor
It sure fixes the looping, which didnt work at all before the bugfix 🙂

What problem are you referring to ?

bozon
Champ in-the-making
Champ in-the-making
It sure fixes the looping, which didnt work at all before the bugfix 🙂

What problem are you referring to ?

I'd like to iterate over collection of elements for java class attached to service task would be called for each element of the collection. There are 3 types of loops: by loops count, by condition and by list iteration. Does that issue fix all them and iteration over collection will work in 5.5 release?

jbarrez
Star Contributor
Star Contributor
Yes - it should. I added some tests to verify and they all succeed.