cancel
Showing results for 
Search instead for 
Did you mean: 

Reference multiInstanceElementVar in activiti:in expression

chris_joelly
Champ in-the-making
Champ in-the-making
Hello,

is it possible to reference the elementVariable of an multiInstanceLoopCharacteristics in an expression in activiti:in?


    <callActivity id="callDoSomething" name="doSomething" calledElement="doSomething" activiti:async="true">
      <extensionElements>
        <activiti:in source="listElem" target="something"></activiti:in>
        <activiti:in source="#{listElem.id}" target="businessKey"></activiti:in>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="listSomething" activiti:elementVariable="listElem"></multiInstanceLoopCharacteristics>
    </callActivity>

I try to find an more or less non-intrusive way to define a "businessKey" as it is not possible to use the Activiti businessKey API due to the missing ability to set an business key after a process instance is started…
2 REPLIES 2

kafeitu
Champ on-the-rise
Champ on-the-rise
Hello,

is it possible to reference the elementVariable of an multiInstanceLoopCharacteristics in an expression in activiti:in?


    <callActivity id="callDoSomething" name="doSomething" calledElement="doSomething" activiti:async="true">
      <extensionElements>
        <activiti:in source="listElem" target="something"></activiti:in>
        <activiti:in source="#{listElem.id}" target="businessKey"></activiti:in>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="listSomething" activiti:elementVariable="listElem"></multiInstanceLoopCharacteristics>
    </callActivity>

I try to find an more or less non-intrusive way to define a "businessKey" as it is not possible to use the Activiti businessKey API due to the missing ability to set an business key after a process instance is started…

The feature is not support now, but you can use other ways.

Create a execution listener of type start on the process that id is callDoSomething.

Xml code:

<process id="doSomething">
    <extensionElements>
      <activiti:executionListener event="start" delegateExpression="${setBusinessKeyOnStartProcessInstance}"></activiti:executionListener>
    </extensionElements>
….
</process>

Java code:


@Service
@Transactional
public class SetBusinessKeyOnStartProcessInstance implements ExecutionListener {

    @Autowired
    FooManager fooManager;
 
    void notify(DelegateExecution execution) throws Exception {
       Object businessKey = execution.getVariable("businessKey");
      fooManager.updateBusinessKey(businessKey);
    }
}

frederikherema1
Star Contributor
Star Contributor
It is possible to reference the loop-variable inside an expression. The value of the loopItem is available on the execution so this is possible.