Filtering Records Using Combo Boxes on Forms

Filtering Records Using Combo Boxes on Forms

  
Team,

I'm unsure if I'm posing this query at the right forum.

Nevertheless, I have a database linked Form widget I'm using to display and/ or save records to the database. Two of the database table fields on the Form are foreign keys to 2 separate database tables. As a result, the Form widget created 2 combo boxes to hold record values of those foreign table fields.

How could I use the selected record in one combo box on the Form widget to filter the list of table records displayed in the second combo box on the Form widget?

The Source Record of the Form is correctly linked to a database table current record list obtained in Preparation. The Form automatically created the 2 combo boxes related to those 2 foreign table fields, but those combo boxes' Source Entities have been set to those foreign database tables. I can't change the Source Records of those combo boxes (containing foreign table fields).

I am unable to select values in combo box 1 to filter records displayed in the second combo box. Does anyone have an easier way of accomplishing this?

Thanks
Seth
 

See attached Table Image for further clarification on my first post.

I created a Form on a page and linked it to Subscriptions Table shown in above image. The Form widget created 2 combo boxes linked with foreign keys (IDs) of ServiceProvider and Service tables respectively. The Combo Box of Service Providers lists all available service providers. The second Services Combo Box lists all services. Please note that in the ServiceProvider table, I listed ServicesId as a foreign key so that all that service provider's services can be liinked to that service provider. In creating a subscription record of a user in the subscriptions table, all I wanted to know is what service a user subscribed to, and from which service provider.

The problem is that, in the Forms widget, when the user has selected the Service Provider to complete their subscription, the second combo box of services shouldn't list all other service providers' services, but should filter the list so that only those services beloning to the selected serviceprovider are displayed. This way, I would be able to limit obvious typing errors by the user from listing wrong services against wrong service providers. 

I am unable to filter records of the Services combo box based on the selected Service Provider.

As mentioned in my previous post, the Source Record of the Form is correctly linked to the above Subscriptions database table's current record list obtained in Preparation. The Form automatically created the 2 combo boxes related to ServiceProvider and Service, but those combo boxes' Source Entities have been respectively set to ServiceProvider and Services tables. I can't change these combo boxes' Source Records to a list so I could perhaps refine the list. I can only select other database tables.

How then, can I filter record values displayed in the second combo box based on the record selected in the first combo box?

Thanks
Seth
Hi Seth,

In the 2nd combobox, you'll have to clear the Source Entity / Attribute properties in order to be able to use the Source Record List property. This will allow you to use an aggregate or a local list variable as a data source.

In the 1st combobox, you can use the On Change event to refresh this data source (and then ajax-refresh the 2nd combobox).

See the attached sample.
Thank you Paulo.

As I couldn't change the Source Entity of the Combo Box automatically created by the Form from an entity to a list, I was unable to do this (that's what happens when one, like me, is a novice). Fortunately, your advise triggered an idea for me to delete the combo box created automatically by the form widget and replace with my own from the design pallete. The new one enabled me to change the Source Entity from a database entity to a record list. I was then able to refresh.

Much appreciated.

PS. How about your help in sourcing me a sample OML and related Java code for reading a mobile device's contact list? I need this not to invade the user's privacy but to improve their convenience of using my App by allowing them to send notices to contacts already in their mobiles' contact lists instead of having them create new contact lists on my App?


Hi Seth,

Note that you don't have to delete the original combobox - just clearing the properties I mentioned (Source Entity / Attribute) should allow you to set the Source Record List property, which is what you need.

For interacting with the device's contact list, see the related OutSystems Now documentation.