cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Indexed condition expression

dwoodbury
Champ in-the-making
Champ in-the-making
Hello:

I'm looking for a way to implement an indexed conditional within a multi-instance sub-process.

The conditional expression is associated with a sequence flow leaving a gateway.

And, I'd like to use the multi-instance loopCounter value to test a condition variable associated with the sub-process.

For example ${approved.loopCounter} would test the value of the process instance variable approved.2 when loopCounter value is 2.

However, when the conditional defined in this manner is evaluated, Activiti throws the following exception:

Class
org.activiti.engine.impl.javax.el.PropertyNotFoundException

Message
Could not find property 2 in class java.lang.Boolean

Is there a way to accomplish what I am trying to do?  I've tried many permutations of the variable definition and conditional expression but cannot find the way to do this.

Thank you!

David Woodbury
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Hi,

It seems to me like you want to add a process variable of type List and add the outcome of every instance (multi-instance) to this list.
Then you can use the loopCounter to get this outcome.

Best regards,

dwoodbury
Champ in-the-making
Champ in-the-making
Hello:

Thank you for the help. Yes, that is what I needed to do.  The Activiti User-Guide is very clear that there are two ways to configure a multi-instance activity.  (1) Set the loopCardinality OR (2) Set the loopDataInputRef and the inputDataItem, however, the Eclipse Designer allows all three to be set, which seems to cause problems with the engine.  I also had used the variable loopCounter as my loopCardinality variable and this may be a bad practice as loopCounter is used by the engine within the sub-process instances.

Here's what I ended up doing:

1. Java Service Task to set assignees (similar to example in Chapter 10 of Activiti in Action)


         String participants = new String("peter,fozzie,kermit");
            String[] participantsArray = participants.split(",");
            ArrayList<String> assigneeList = new ArrayList<String>();
            for (String assignee : participantsArray) {
                    assigneeList.add(assignee);
            }
            List<ArrayList<String>> assigneeGroupList = new ArrayList<ArrayList<String>>();
            assigneeGroupList.add(assigneeList);
            assigneeGroupList.add(assigneeList);
            assigneeGroupList.add(assigneeList);
            assigneeGroupList.add(assigneeList);
            execution.setVariable("assigneeGroupList", assigneeGroupList);

2. Configure just the  loopDataInputRef and the inputDataItem elements in the BPMN and use loopCounter as index into the List.

   <subProcess id="subprocess1" name="Obtain CAB Approvals">
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopDataInputRef>assigneeGroupList</loopDataInputRef>
        <inputDataItem name="assigneeList"></inputDataItem>
        <completionCondition>${nrOfCompletedInstances/nrOfInstances == 1}</completionCondition>
      </multiInstanceLoopCharacteristics>
      <startEvent id="startevent2" name="Start"></startEvent>
      <userTask id="usertask5" name="Approve CAB Request" activiti:candidateUsers="${assigneeGroupList.get(loopCounter)}" activiti:formKey="/changeRequest/approval"></userTask>