# Bonita 6.3.3 - Update LIST Variable from groovy

**URL:** https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122
**Category:** Q&A
**Created:** [9 September 2014 13:57 UTC](https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122 "2014-09-09T13:57:43Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)
#### Post date: [9 September 2014 13:57 UTC](https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122/1 "2014-09-09T13:57:43Z")

</div>

Hi there,

I’m still relatively new to Bonita level coding and am trying to use the code example [here](http://community.ofelia.com/groups/usage-operation-5x/resolved-setting-list-variables-setprocessinstancevariable) to populate a LIST variable from Groovy Script but with no success…it’s using code I don’t know…

I don’t know how to use UUID query runtime etc. and keep getting an error.

So as a full code example…can you show me how it’s done…

I know how to do single Strings that’s here, and I’ve tried that with no success…the code will be executed several times during a process so need to know the step it’s on to fill the variable. I think this code only works at process level, i need it at step level…

`
import org.bonitasoft.engine.api.ProcessRuntimeAPI;
ProcessRuntimeAPI processRuntimeAPI = apiAccessor.getProcessAPI();
String processName = processRuntimeAPI.getProcessInstance(processInstanceId).getName();
List l1 = new ArrayList();
l1.add(“text1”);
l1.add(“text3”);
l1.add(“text2”);
`

`apiAccessor.getProcessAPI().updateProcessDataInstance(
“definedListVar”,
processInstanceId,
l1);
`

Many thanks for your help in advance,

best regards  
Seán

---

<div class="post-metadata">

### Author: ![yannick.lombardi](https://avatars.discourse-cdn.com/v4/letter/y/8e8cbc/32.png) [@yannick.lombardi](https://community.ofelia.com/u/yannick.lombardi)
#### Post date: [9 September 2014 14:05 UTC](https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122/2 "2014-09-09T14:05:32Z")

</div>

Hi,  
The example you are looking is for the version 5.X of Bonita. UUID doesn’t work with 6.X.  
To populate a list with some from a groovy script, you can use a Script Task.  
In the Operations tab of this task, you put your variable in the left, and in the right member you create a script.  
You can use this script :  
  
List l1 = new ArrayList();  
l1.add(“text1”);  
l1.add(“text3”);  
l1.add(“text2”);  
return l1;

---

<div class="post-metadata">

### Author: ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)
#### Post date: [9 September 2014 14:11 UTC](https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122/3 "2014-09-09T14:11:23Z")

</div>

Thanks Yannick,

BUT, I don’t want to return the list - I want to SET the List Variable…they are two different things…

Similar to the code I showed which updates a variable direct without a return.

`
apiAccessor.getProcessAPI().updateProcessDataInstance("thisIsMyVar", processInstanceId, "This is the data");
`

thanks

---

<div class="post-metadata">

### Author: ![yannick.lombardi](https://avatars.discourse-cdn.com/v4/letter/y/8e8cbc/32.png) [@yannick.lombardi](https://community.ofelia.com/u/yannick.lombardi)
#### Post date: [9 September 2014 14:15 UTC](https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122/4 "2014-09-09T14:15:19Z")

</div>

What I said is to SET a variable. Your variable take the value that is returned by the script.

---

<div class="post-metadata">

### Author: ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)
#### Post date: [9 September 2014 14:36 UTC](https://community.ofelia.com/t/bonita-6-3-3-update-list-variable-from-groovy/5122/5 "2014-09-09T14:36:47Z")

</div>

Ok, sorry, but still not what I want,

This is what I want to do…

this occurs multiple times per process

Step → On-enter  
Connector to fill list - groovy - set list variable with “a1”, “a2”, “a3” (non-changable by customer)  
Connector to retrieve data based on List (returns a new ListOut) - java - get x where col1 = a1 etc…

Step → Display  
display the returned ListOut for text/data to be shown in fields “a1”, “a2”, “a3”

The data “a1”, “a2”, “a3” can be a-z and 1-100 depending on page…

I know another way to do it but…it means a lot of redesign and rework, and “a-z and 1-100” calls to groovy…urgh…

the 5 version I showed, examples what I want it to do…but how do I do it in 6?

Thanks and regards  
Seán
