# Setting value list from array - inconsistent results

**URL:** <https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227>\
**Category:** Classic Servoy\
**Created:** [February 9, 2004, 4:28pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227 "2004-02-09T16:28:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 9, 2004, 4:28pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/1 "2004-02-09T16:28:56Z")

</div>

I have a privileges table where different user types have a single field with check boxes with up to 7 values.

I want to create an array from the selected values using:

var myArray = my\_check\_field.split(‘\n’);

Then I want to use the array in a value list:

application.setValueListItems (‘cust\_list’, myArray);

The results I get are not consistent - sometimes it works fine and other times I get a mixture of correct and incorrect (i.e. NOT selected) values, often with the last value in the list truncated i.e. ‘pro’ instead of ‘providers’ or ‘admi’ instead of ‘administrators’.

Is this a bug or am I going wrong?

OS X 10.3, java 1.4.1 and 2.0rc3

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 9, 2004, 4:53pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/2 "2004-02-09T16:53:35Z")

</div>

Do you also have a, sometimes, empty list? Because that’s what I have sometimes (and not reproducable)… Same platform…

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 9, 2004, 10:15pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/3 "2004-02-09T22:15:53Z")

</div>

> IT2BE:  
> Do you also have a, sometimes, empty list? Because that’s what I have sometimes (and not reproducable)… Same platform…

Yes, it has happened.

I have found a fix for now:  
I noticed that if I accessed the field and changed the check boxes first, then the array and the value list would always be correct. So I tried:

```auto
my_check_field = my_check_field;//reset the field to the current values

```

before setting the array and then the value list. Now the value list always comes back correctly!

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 11, 2004, 11:25am UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/4 "2004-02-11T11:25:26Z")

</div>

can you give me an example (solution) of what works and what not?

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 11, 2004, 12:09pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/5 "2004-02-11T12:09:28Z")

</div>

> jcompagner:  
> can you give me an example (solution) of what works and what not?

Actually am I now back to square 1 with inconsistent value lists again - my above solution was apparently only temporary! It is hard to send you an example because I cannot reproduce the problem consistently.

Am still trying…

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 11, 2004, 12:26pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/6 "2004-02-11T12:26:01Z")

</div>

And reproducing the issue is exactly my issue too…

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 11, 2004, 4:15pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/7 "2004-02-11T16:15:58Z")

</div>

Have you noticed changes to the checkboxes? If I have a list of 7 values all checked, when this error hits the first and last checkboxes have been unchecked as well! As far as I can see there is nothing in any of the scripts that affects tha actual checkbox selections.

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 11, 2004, 10:34pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/8 "2004-02-11T22:34:12Z")

</div>

I think I have tracked this down. If any of the values selected in the check box field contain more than one word, then setting a value list from an array containing those values fails. If all the selected values in the checkbox field are single words only then the array created by using .split works correctly! I can reproduce this consistently and will attach a sample solution tomorrow.

In my solution there was a further complication in that the values for the checkbox field were themselves pulled from a related table and this also seems to cause problems. I will try setting the initial checkbox values also using an array and setValueListItems to see if this works better, but the ‘more than one word’ issue remains.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 12, 2004, 11:17pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/9 "2004-02-12T23:17:08Z")

</div>

do you guys already have some reproducable test solution?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 13, 2004, 12:12am UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/10 "2004-02-13T00:12:53Z")

</div>

Johan, I will put some effort into that tomorrow…

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 13, 2004, 4:03pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/11 "2004-02-13T16:03:16Z")

</div>

I have built a test solution with one valuelist.

I didn’t seen ANY issue unfortunately.

I also checked my existing solution over and over for things I do wrong etc.

Do only things I can say are:

- I do not see any pattern. I haven’t seen the issue appearing today…
- The valuelist are created, I check that every startup (also when it goes wrong)…
- It looks like the valuelist is emptied while the solution is already open… Can’t think of anything else…
- BTW these finding count for both developer and client…

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 13, 2004, 11:19pm UTC](https://forum.servoy.com/t/setting-value-list-from-array-inconsistent-results/1227/12 "2004-02-13T23:19:47Z")

</div>

The valuelist suddenly again empty (or default) will be fixed in 2.0RC7

but for this

> The results I get are not consistent - sometimes it works fine and other times I get a mixture of correct and incorrect (i.e. NOT selected) values, often with the last value in the list truncated i.e. ‘pro’ instead of ‘providers’ or ‘admi’ instead of ‘administrators’.

i really need a sample solution that ‘sometimes’ does this.
