# Dynamic population of an existing combobox

**URL:** <https://forum.servoy.com/t/dynamic-population-of-an-existing-combobox/10070>\
**Category:** Classic Servoy\
**Created:** [December 29, 2008, 6:11pm UTC](https://forum.servoy.com/t/dynamic-population-of-an-existing-combobox/10070 "2008-12-29T18:11:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![markhooper](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@markhooper](https://forum.servoy.com/u/markhooper)\
**Post date:** [December 29, 2008, 6:11pm UTC](https://forum.servoy.com/t/dynamic-population-of-an-existing-combobox/10070/1 "2008-12-29T18:11:40Z")

</div>

I’m new to the Solution Model paradigm - I’m trying to use the Solution Model to dynamically fill an existing combobox on an existing form - so far its not working.

My existing form is called ‘seis\_set\_query’, the existing combobox field is called ‘fv\_current\_search’  
In this simple example I just want the value ‘Test1’ to show up in the combobox…

```auto
  var lv_valuelist = solutionModel.newValueList('user_queries', SM_VALUELIST.CUSTOM_VALUES);
  lv_valuelist.separator = '|';
  lv_valuelist.customValues = 'Test1|bla';

  var lv_form = solutionModel.getForm('seis_set_query');
  var lv_field = lv_form.getField('fv_current_search');
  lv_field.valuelist = lv_valuelist;

```

The code executes without error but there is no value in the combobox.  
Can anyone spot the problem ?

Thanks in advance  
Mark

------UPDATE------  
I got this to work if I ran this code BEFORE the form was loaded/shown for the first time - it seems that it doesn’t work if the form is already loaded/shown.  
The code I used is slightly different from what was originally posted…

```auto
  var lv_valuelist = solutionModel.newValueList('user_queries', SM_VALUELIST.CUSTOM_VALUES);
  lv_valuelist.separator = ' ';
  lv_valuelist.customValues = 'Test1|bla1\r\nTest2|bla2';
  var lv_form = solutionModel.getForm('seis_set_query');
  var lv_field = lv_form.getField('fv_current_search');
  lv_field.valuelist = solutionModel.getValueList('user_queries');

```

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [December 29, 2008, 10:03pm UTC](https://forum.servoy.com/t/dynamic-population-of-an-existing-combobox/10070/2 "2008-12-29T22:03:36Z")

</div>

Hi Mark,

you already got your answer: creating objects /changing properties using the solutionModel have to be done before a certain form is loaded.

Reading properties isn’t a problem at all, this can be done at anytime.

---

<div class="post-metadata">

**Author:** ![seanthomasdevlin](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/seanthomasdevlin/32/5_2.png) [@seanthomasdevlin](https://forum.servoy.com/u/seanthomasdevlin)\
**Post date:** [December 30, 2008, 5:38pm UTC](https://forum.servoy.com/t/dynamic-population-of-an-existing-combobox/10070/3 "2008-12-30T17:38:13Z")

</div>

Hi Mark,

You shouldn’t have to use the solution model for this.  
You can pre create an empty value list and use the application node’s setValueListItems() method to change the items in the value list.

If for some reason you do need to change the field’s value list (i.e. between two value lists) then you would need the solution model.  
You’ll have to unload the form using the history.remove() method before you show it. This will cause the changes to be in effect.

Hope this helps,  
Sean

---

<div class="post-metadata">

**Author:** ![markhooper](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@markhooper](https://forum.servoy.com/u/markhooper)\
**Post date:** [January 9, 2009, 4:26pm UTC](https://forum.servoy.com/t/dynamic-population-of-an-existing-combobox/10070/4 "2009-01-09T16:26:31Z")

</div>

I took your advice and the population of my combobox works just fine, thanks Sean!

Cheers  
Mark
