# Using element variable (multi instance) in expression in a form

**URL:** <https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526>\
**Category:** Flowable Application\
**Created:** [March 6, 2019, 3:41pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526 "2019-03-06T15:41:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luc](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@Luc](https://forum.flowable.org/u/Luc)\
**Post date:** [March 6, 2019, 3:41pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/1 "2019-03-06T15:41:49Z")

</div>

I have a service task that outputs a `java.util.ArrayList<string>`. I would like to create a user task for each item in that array. The user task should have a form in which the corresponding item is referenced. I have included a screenshot of my failed attempt below.

Suppose that `items = ["A", "B", "C"]`  
This does indeed create 3 tasks: “Form: A”, “Form: B”, “Form: C”.  
So far so good.  
However, when I open any of the three forms, the expression within the form always evaluates to “C” (the last item in the array). Why does this happen? And how can I prevent this?

Note that everything works as expected if I use multi-instance type ‘sequential’ instead of ‘parallel’, but this is not an option because I would like to start all tasks at the same time.

![Process](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/flowable/original/2X/2/28a4b6161b8eba70a87a1ead8828b8f3b0c35838.png)

I couldn’t include a screenshot of the form as new users are only allowed to use one image. The form only has one expression: `${ item }`.

---

<div class="post-metadata">

**Author:** ![paulrda](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@paulrda](https://forum.flowable.org/u/paulrda)\
**Post date:** [May 4, 2019, 10:32pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/2 "2019-05-04T22:32:13Z")

</div>

im also looking for a solution for this problem. as above mentioned i get same value for Element variable for all multi instances when i choose sequential false(parallel). can anyone suggest a solution to get element variable values in collection for each instance.

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [May 16, 2019, 5:52am UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/3 "2019-05-16T05:52:59Z")

</div>

Hi,

Following example could help you:

> <https://github.com/flowable/flowable-engine/blob/bb8b8814e326112f4081904223ee7fec52e866de/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/multiinstance/MultiInstanceTest.java#L345>

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![snaikar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/snaikar/32/1366_2.png) [@snaikar](https://forum.flowable.org/u/snaikar)\
**Post date:** [September 20, 2019, 6:06pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/4 "2019-09-20T18:06:52Z")

</div>

Any luck on this I am facing the same issue

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [September 21, 2019, 2:16pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/5 "2019-09-21T14:16:00Z")

</div>

Here is the related bug:

> <https://github.com/flowable/flowable-engine/issues/1743>

---

<div class="post-metadata">

**Author:** ![dumbird](https://avatars.discourse-cdn.com/v4/letter/d/edb3f5/32.png) [@dumbird](https://forum.flowable.org/u/dumbird)\
**Post date:** [January 24, 2020, 5:30pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/6 "2020-01-24T17:30:39Z")

</div>

![Screen Shot 2020-01-24 at 9.23.53 AM](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/4/4e89380f86205cd6cdcdee6a9c6e04e975e3bed8.png)  
Is this fixed? I’m learning Flowable and created a subprocess using multi-instance as shown in the screenshot. The decision task outputs a variable depending on a field of the element in the input list, which will be in turned used to create a user task with a form to show. This works fine if the the multi-instance is sequential, but once it’s changed to parallel, all the tasks get the last variable created by the decision task. How should I solve this? Thanks.

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 24, 2020, 7:19pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/7 "2020-01-24T19:19:59Z")

</div>

Which version of Flowable are you using? 6.5.0 was released in the last couple of days and should resolve this.

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 24, 2020, 8:17pm UTC](https://forum.flowable.org/t/using-element-variable-multi-instance-in-expression-in-a-form/3526/8 "2020-01-24T20:17:29Z")

</div>

It appears that decision tables are putting their output values on the overall process and therefore overwriting each other on each execution. I’ve opened a [bug for it](https://github.com/flowable/flowable-engine/issues/2143). This is slightly different, but related to the previous issue.
