combo box dynamically populated

combo box dynamically populated

It's been now 4 days I try to have a combo box populated from a sql query that filers values from a table.
I always get an ampty list of choices no matter what i do. If i use the :
If i use the Source Enty Structure to the full table (COMPANIES in sales assistant) it works
But i want to FILTER value to choose. So i use the "SOURCE RECORD LIST"
And create a FUNCTION that give a RECORDLIST type of structure COMANIES.
is there any working example for that ?
Hi Matteo, and welcome to the OutSystems community forums.

Indeed, the combo box is not the easiest widget to work with. However, after we get our heads around how it works, it's quite easy to use.

I'll recommend you read through this specific post where some of the most common problems people have with that widget.

If I'm getting correctly what you're saying, you would just need to add a boolean structure to a query where you retrieve the data that you want to show in the combo box.

Let us know if this helps.


Paulo Tavares

Maybe I misunderstand your problem but when you say 'dynamic' you mean what exactly ?

Also filter in what sense ?

From what I gather you want have a table called Companies, and show only those records that match a certain condition right ?

If so the process is simple as follows (I leave out the creation of the entities and all, you have those already).

In the 'Preparation' action of the web-page that has the Combobox in it add a Query to the Method flow. It has to be preparation since you want this to be done before the page displays. Alternatively you can trigger the query of a button or I guess pretty much any event you need. If you need to update your combobox after your page is already displayed you will have to give it a name (default is blank) and use Ajax refresh to refresh the combobox after the query is run.

Adding a query is a simple matter of dragging the query widget into your process flow for 'Preparation' (or whatever action is supposed to do the load after the page is shown already). Doubleclicking the Query will allow you to fine tune it to your needs (which entities, if there are conditions you can add those too and match them to an input variable ...

All you need to do then is set 4 values on the combobox :

- Source Record List is set to the NameOfYourQuery.List value
- Source entity/structure is set to the entity that holds the data (all it gets from this is what fields this entity has, not the data it self).
- Source label is set to which field you want to be used in the list (like name, description etc, otherwise it would just show the unique record ID number), this is alse where the previous value comes in since thats how it knows which fields each record in the list has.
- Variable, this will be set to the record ID of the record you select in the combobox. It has to match datatypes with the ID of course.

I have added a simple example for you as attachment to this post. It will show all contacts in the Contacts table with Company set LIKE 'XYZ' on load. You can then fill in the input field with some other 3 letter code (AAA is sugested) and the combobox will update with a different list of contacts. XYZ has 2 contacts, AAA has 1 contact, type anything else in the input field and the box is empty.

Should get you going.
Thanks  a lot,
      now i've overcome all combo related issues! Let's fo to the next!
Thanks again