cancel
Showing results for 
Search instead for 
Did you mean: 

Set calledElement using expression at runtime with Multi Instance Loop

sunshare
Champ in-the-making
Champ in-the-making
Hey,

I am having a issue with setting the calledElement at runtime for CallActivity with MultiInstanceLoopCharacteristics. This is how I created my CallActivity.


        CallActivity callActivity = new CallActivity();
        callActivity.setId(callAcitityId);
        callActivity.setName(callAcitityId);
        callActivity.setCalledElement("${processToCall}");

        IOParameter ioRowParameter = new IOParameter();
        ioRowParameter.setSource("row");
        ioRowParameter.setTarget("row");

        //This is my thought, that if we can pass in the processToCall from the MultiInstanceLoopCharacteristics or from the parent process. Then, it can resolve my calledElement expression ${processToCall}
        IOParameter ioProcessKeyParameter = new IOParameter();
        ioProcessKeyParameter.setSource("processToCall");
        ioProcessKeyParameter.setTarget("processToCall");

        callActivity.setInParameters(Arrays.asList(ioRowParameter));

        MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics();
        multiInstanceLoopCharacteristics.setSequential(false);
        multiInstanceLoopCharacteristics.setInputDataItem("rows");
        multiInstanceLoopCharacteristics.setElementVariable("row");

        callActivity.setLoopCharacteristics(multiInstanceLoopCharacteristics);

        return callActivity;


My problem is MultiInstanceLoopCharacteristics only supports collection data, which I used for my data rows. How can I pass in the processToCall into my CallActivity instance to resolve my calledElement at runtime?

Let me know if you need more detail or anything is unclear. Thanks,
Lesong
1 REPLY 1

sunshare
Champ in-the-making
Champ in-the-making
After referring to this post https://forums.activiti.org/content/diagram-not-generated-when-using-expression-callactivity, I change my expression to get variable from the execution. So, it will be something like:
<code>
        callActivity.setCalledElement("${execution.getVariable('row').get('proocessToCall')}");
</code>

Then, I put a processToCall to my loop collection. Problem solved! Yeah~