# Multi instance variable aggregation result in empty json

**URL:** <https://forum.flowable.org/t/multi-instance-variable-aggregation-result-in-empty-json/10077>\
**Category:** Flowable Engine\
**Created:** [January 6, 2023, 4:25pm UTC](https://forum.flowable.org/t/multi-instance-variable-aggregation-result-in-empty-json/10077 "2023-01-06T16:25:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![theghost5800](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@theghost5800](https://forum.flowable.org/u/theghost5800)\
**Post date:** [January 6, 2023, 4:25pm UTC](https://forum.flowable.org/t/multi-instance-variable-aggregation-result-in-empty-json/10077/1 "2023-01-06T16:25:25Z")

</div>

Hello, I am trying to use [multi instance variable aggregation](https://www.flowable.com/blog/multi-instance-variable-aggregation) feature in BPMN diagrams but unfortunately with no success.  
I have one bpmn diagram which has call activity configured as multi instance and this call activity execute another bpmn diagram which has one service task calling JavaDelegate implemented class. Inside this class variable is set by calling “execution.setVariable(“servicesToCreate”,“someValue”)” and this is done by multiple instances of that call activity. After all instances of call activity finished I try to read aggregated variable from parent bpmn diagram in service task but I receive ArrayNode with multiple JsonNode objects(count in the list depends on multi instance execution) but they are empty and I cannot find why I can’t get these values.

part from my bpmn xml:

> \< **callActivity** id=_“processBatchesSequentially”_ name=_“Process Resource Batches Sequentially”_ flowable:async=_“true”_ calledElement=_“processBatches”_ flowable:calledElementType=_“key”_ flowable:inheritVariables=_“true”_ flowable:completeAsync=_“true”_ flowable:fallbackToDefaultTenant=_“false”_\>
> 
> \< **multiInstanceLoopCharacteristics** isSequential=_“true”_ flowable:collection=_“batchesToProcess”_ flowable:elementVariable=_“batchToProcess”_\>
> 
> \< **extensionElements** \>
> 
> \< **flowable:variableAggregation** target=_“servicesToCreateAgg”_\>
> 
> \< **variable** source=_“servicesToCreate”_ \>\</ **variable** \>
> 
> \</ **flowable:variableAggregation** \>
> 
> \</ **extensionElements** \>
> 
> \</ **multiInstanceLoopCharacteristics** \>
> 
> \</ **callActivity** \>

---

<div class="post-metadata">

**Author:** ![theghost5800](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@theghost5800](https://forum.flowable.org/u/theghost5800)\
**Post date:** [January 9, 2023, 3:10pm UTC](https://forum.flowable.org/t/multi-instance-variable-aggregation-result-in-empty-json/10077/2 "2023-01-09T15:10:58Z")

</div>

I have identified why this feature doesn’t work in my scenario. It turns out that multi instance variable aggregation doesn’t work for multi instance call activities. All variables should be set in the same execution in order to enable this feature which I think it’s not good solution.  
Could we expect this feature to work with multi instance call activities?

---

<div class="post-metadata">

**Author:** ![CElbersen](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@CElbersen](https://forum.flowable.org/u/CElbersen)\
**Post date:** [February 2, 2023, 10:14am UTC](https://forum.flowable.org/t/multi-instance-variable-aggregation-result-in-empty-json/10077/3 "2023-02-02T10:14:53Z")

</div>

Not entirely sure but I’ve had this working with call activities in a parallel setting instead of sequential. I see no reason why this wouldn’t work for sequential.  
Why do you have completeAsync on true?

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [February 24, 2023, 1:02pm UTC](https://forum.flowable.org/t/multi-instance-variable-aggregation-result-in-empty-json/10077/4 "2023-02-24T13:02:33Z")

</div>

Hey @theghost5800 ,

> [@theghost5800](#):
>
> It turns out that multi instance variable aggregation doesn’t work for multi instance call activities

This is incorrect. As @CElbersen said it works properly for call activities.

The reason why it doesn’t work for you, is due to the fact that you have not defined any out parameters for your call activity. This means that when the called process is done, none of its variables are passed to the existing process instance and thus you get empty objects.

Cheers,  
Filip
