# application.setValueListItems issue

**URL:** <https://forum.servoy.com/t/application-setvaluelistitems-issue/7722>\
**Category:** Classic Servoy\
**Created:** [June 26, 2007, 4:15pm UTC](https://forum.servoy.com/t/application-setvaluelistitems-issue/7722 "2007-06-26T16:15:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidaarong](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@davidaarong](https://forum.servoy.com/u/davidaarong)\
**Post date:** [June 26, 2007, 4:15pm UTC](https://forum.servoy.com/t/application-setvaluelistitems-issue/7722/1 "2007-06-26T16:15:25Z")

</div>

I have a form that is based on my Order\_Details table with a combobox that displays items from my Products table via a value list. However, when I use application.setValueListItems my value list does not change and shows all my products. What I want to display are the products that are marked as “Current” (current\_product = ‘1’).

Outline of issue:

I have 1 value list (Products) attached to my combobox (Product\_ID) from table order\_details  
I have 1 method that is attached to onShow of the order\_dialog form (on\_load\_new\_record)  
I have 1 layout based on the Order\_Details table (order\_dialog)

Valuelist: Products  
Database Values:  
product\_id (Return in dataprovider)  
name (Show in field/list)

Method: on\_load\_new\_record

```auto
controller.newRecord()
order_id = globals.gOrder_id;
elements.Product_ID.requestFocus(true)

var query = "SELECT product_ID FROM products WHERE current_product = '1'";
var maxReturnedRows = 1000;
var name = elements.Product_ID.getValueListName();
var d = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturnedRows);
application.setValueListItems( name, d);

```

Layout is called as a showFormInDialog via this method:

```auto
	application.showFormInDialog(forms.Order_Dialog,-1,-1,492,222,'Add Item',false,false,true)

```

After reading through the boards I found out that you need to have the combobox as non-editable, which i have done however this made no difference.

Any ideas?

Thank you,  
David

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [June 26, 2007, 4:23pm UTC](https://forum.servoy.com/t/application-setvaluelistitems-issue/7722/2 "2007-06-26T16:23:55Z")

</div>

Some remarks:

1. If you want to fill a value list by a custom query, you should set the value list to “custom” and not define anything (the value list will be filled with what you queried instead of using the definition that you described)
2. Your query only returns the product\_id, but not the name that your user probably wants to use. Change the query to something like “SELECT product, product\_id …”
3. You could also create a relation from a global variable with value 1 to your products table, column “current\_product”. The relation will “see” all current products. In the value list definition you can the use that relation.

Hope this helps.

Patrick

---

<div class="post-metadata">

**Author:** ![davidaarong](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@davidaarong](https://forum.servoy.com/u/davidaarong)\
**Post date:** [June 26, 2007, 5:08pm UTC](https://forum.servoy.com/t/application-setvaluelistitems-issue/7722/3 "2007-06-26T17:08:19Z")

</div>

Thanks Patrick!

Number 3 is a great idea  
"3. You could also create a relation from a global variable with value 1 to your products table, column “current\_product”. The relation will “see” all current products. In the value list definition you can the use that relation. "

That solved the issue with no coding!
