# HOW TO GET CUSTOM VALUELIST IN COMBOBOX

**URL:** <https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141>\
**Category:** Classic Servoy\
**Created:** [July 5, 2012, 2:25pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141 "2012-07-05T14:25:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hardina09](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hardina09](https://forum.servoy.com/u/hardina09)\
**Post date:** [July 5, 2012, 2:25pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/1 "2012-07-05T14:25:53Z")

</div>

I am having combobox in form . I have created valuelist programmatically using below code

```auto
<somecode>
var ds = databaseManager.getDataSetByQuery(<servnm>,<sql>,arg,maxrow)
var arr1 = dataset.getColumnAsArray( 1 )
var arr2= dataset.getColumnAsArray( 2 )
application.setValueListItems( "valuelist'', arr1,arr2);

```

But thing is how to display valuelist in combobox. Any suggestions.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [July 5, 2012, 2:39pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/2 "2012-07-05T14:39:34Z")

</div>

Hi,

You first have to create this valuelist with the name ‘valuelist’ in Developer, then assign that that the combobox. After this the code can fill the valuelist and it will show up.  
Another way would be to do all this using the solutionModel.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![hardina09](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hardina09](https://forum.servoy.com/u/hardina09)\
**Post date:** [July 5, 2012, 3:39pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/3 "2012-07-05T15:39:17Z")

</div>

I’m using SolutionModel to create valuelist. Valuelist is created but when assign to combobox its sitll empty. Can you please explain me in detail how to create valuelist and assign to combobox

---

<div class="post-metadata">

**Author:** ![hardina09](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hardina09](https://forum.servoy.com/u/hardina09)\
**Post date:** [July 5, 2012, 6:13pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/4 "2012-07-05T18:13:34Z")

</div>

I got to know that sql query in Dataset is wrong. Can anyone please correct the syntax

var sql=“SELECT dept\_id” + “’ - '” +" dept\_name from departments"; //syntax error.  
var ds=databaseManager.getDatasetByQuery(‘servname’,sql,null,10);

Please suggest.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [July 5, 2012, 6:23pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/5 "2012-07-05T18:23:04Z")

</div>

> hardina09:  
> var sql=“SELECT dept\_id” + “’ - '” +" dept\_name from departments"; //syntax error.

So you want to concatenate the 3 values together ?  
Depending on what database backend you are using you can use the following syntax:

PostgreSQL/Oracle

```auto
var sql="SELECT dept_id || ' - ' || dept_name from departments";

```

Sybase/MSSQL

```auto
var sql="SELECT dept_id + ' - ' + dept_name from departments";

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)\
**Post date:** [July 6, 2012, 6:52am UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/6 "2012-07-06T06:52:32Z")

</div>

If you are not sure which backend Db is used you can first concatenate and then build the query

```auto
var arg = dept_id + '-' + dept_name;
var sql="SELECT ' + arg + ' FROM departments";

```

If you are using MySQL the right syntax could be

```auto
var sql="SELECT CONCAT(dept_id,' + '-' + ',dept_name) FROM departments";

```

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [July 6, 2012, 6:58am UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/7 "2012-07-06T06:58:36Z")

</div>

Hi Rioba,

> rioba:  
> If you are not sure which backend Db is used you can first concatenate and then build the query
> 
> ```auto
> var arg = dept_id + '-' + dept_name;
> 
> ```

var sql=“SELECT ’ + arg + ’ FROM departments”;

> ```auto
> 
> ```

That doesn’t work because then the database wants substract the value of dept\_name from dept\_id. Concatenation of columns in your query need to be done by SQL.  
It’s a different matter if you want to pass values that you get from Servoy.

---

<div class="post-metadata">

**Author:** ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)\
**Post date:** [July 6, 2012, 7:17am UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/8 "2012-07-06T07:17:54Z")

</div>

Hi ROCLASI,

I stand corrected. I treated them as variables, not columns. Sorry. I have therefore amended also the syntax for the MySQL query

---

<div class="post-metadata">

**Author:** ![hardina09](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hardina09](https://forum.servoy.com/u/hardina09)\
**Post date:** [July 11, 2012, 9:17pm UTC](https://forum.servoy.com/t/how-to-get-custom-valuelist-in-combobox/16141/9 "2012-07-11T21:17:19Z")

</div>

Thanks all.
