Populate a List of Values Based on Another LOV
Within a dynamic form, you can use one drop-down menu to determine what appears in a second menu.
For example, suppose you want to present a list of states as a List of Values (LOV). When the user selects a state, a second LOV is populated with the cities in that state.
Here's what this might actually look like in your application: the first field, Select State, displays a list of states for users to select from:
Description of the illustration selectstate.png
Once the user chooses a state—say, Alaska—the next field displays a list of Alaskan cities for the user to choose from:
Description of the illustration selectcity.png
For this to work, there must be a relationship between the data sources associated with each drop-down list. In this example, the data sources are two business objects (but they could come from another source as well, such as a service connection): state
and city
. Here's an excerpt of data from the state
business object:
Description of the illustration statebodata.png
And here's some data from the city
business object:
Description of the illustration citybo.png
Let's take a closer look at the city
business object—specifically, the state
field. The person who created this business object set up this field as a reference type. A reference type field refers to a key field (in this case, the id
field) in the state
business object, to link the two business objects together.
Notice that the id
field in the state
business object assigns a unique number to each state, and that this number also appears in the city
business object's state
field. For example, Alaska has a value of 1 in the state
business object, while cities IN Alaska have the value "Alaska (1)" in the city
business object's state
field. When VB Studio sees a city with Alaska(1) in the state field, it knows to grab the state with a value of 1 in the state
business object. It's important to understand this relationship a bit so you'll understand what's going on as we move through this procedure.
To populate a list of values in a drop-down menu when an item in another LOV is selected:
Let's preview the page by selecting the Page Designer's Live mode. Select a state, then notice how the city drop-down list shows only the cities in that state:
If you open the list of cities without first selecting a state, the action chain won't be triggered, so the list won't be filtered. In other words, you'll see all the cities for all the states.