javabpmnflowable

Flowable Multi Instance Call Activity - Output Parameters


Having the following definition in my BPMN model (Flowable Engine):

<callActivity id="111-example-111" name="CALLING_SUBPROCESS_MULTIINSTANCE" calledElement="SOME_SUBPROCESS" flowable:calledElementType="key" flowable:fallbackToDefaultTenant="false">
<extensionElement>
    <flowable:in source="INPUT_VAR" target="SUB_INPUT_VAR"></flowable:in>
    <flowable:out source="SUB_OUTPUT_VAR" target="OUTPUT_VAR"></flowable:out>
</extensionElement>
<multiInstanceLoopCharacteristics isSequential="true" flowable:collection="SOME_COLLECTION" flowable:elementVariable="SOME_ELEMENT"></multiInstanceLoopCharacteristics>

call activity is correctly processed but I am unable to pass the output variable SUB_OUTPUT_VAR to the parent process. I tried some other syntax like:

<flowable:out source="SUB_OUTPUT_VAR" target="OUTPUT_VAR_${loopCounter}"></flowable:out>

because each loop can produce SUB_OUTPUT_VAR and I want to pass all of them to the parent process. But it didn't help.

Is there any way to do it using Flowable BPMN Engine?


Solution

  • Collecting variables from a multi instance is a problem that has been in Flowable (and other similar engines for a while).

    Your proposed solution with

    <flowable:out source="SUB_OUTPUT_VAR" target="OUTPUT_VAR_${loopCounter}"></flowable:out>
    

    However, in the upcoming 6.7.0 release. There will be a better solution for this. You would be able to use Variable Aggregations.

    e.g.

    You would be able to define the output as

    <flowable:out source="SUB_OUTPUT_VAR" target="OUTPUT_VAR"></flowable:out>
    

    and then in the multiInstanceLoopCharacteristics you can define something like:

    <multiInstanceLoopCharacteristics isSequential="false" flowable:collection="SOME_COLLECTION" flowable:elementVariable="SOME_ELEMENT>
        <extensionElements>
            <flowable:variableAggregation target="outputResult">
                <variable source="OUTPUT_VAR" target="OUTPUT_VAR"></variable>
            </flowable:variableAggregation>
        </extensionElements>
    </multiInstanceLoopCharacteristics>
    

    Doing this it will create a JSON Array result with the following structure:

    {
        "OUTPUT_VAR": "result"
    }