Situation
You have a screen with two drop-down boxes and you need to filter the second based on data selected in the first one.
Example
You have these two fields on the screen:
- Category
- Product
When you select a category you then want to select only products in that category.
Solution
-
Create a filtered lookup
a) Create a filter on theProduct
entity (e.g.GetByCategoryId
)
b) Right-click on theProduct
entity and select Actions > Create Lookup.
c) Name the lookupProduct_ByCategoryId
d) Select theGetByCategoryId
in the List Filter and finish the wizard.
Now theProduct
drop-down based on this lookup will expect aProduct_parCategoryId
parameter when the dropdown part is opened. -
Add entity field dependency
You need to tell the front-end that the fields will be actually cascading. For this you need to create a dependency between the fields. When theCategory
field’s value changes, theProduct
field will reset, expecting you to enter a new value.
a) Right click on the dependentProduct
entity field.
b) Select New > Dependency
c) Select theCategory
field. -
Select the lookup in the drop-down in the screen designer
a) Open the screen section
b) Select theProduct
drop-down (or put it to the section if it is not there yet)
c) Go to Properties (F4) and check that the Lookup property is set to your filtered lookupProduct_ByCategoryId
d) Now go to the ParameterMappings property and click on […]
e) You will see theProduct_parCategoryId
parameter.
d) Put the category’s field name in the ColumnName, in this caserefCategoryId
.
This way you tell theProduct
drop-down that it should use the value from theCategory
to filter the products.