How to filter a drop-down box (cascading drop-downs)?

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

  1. Create a filtered lookup
    a) Create a filter on the Product entity (e.g. GetByCategoryId)
    b) Right-click on the Product entity and select Actions > Create Lookup.
    c) Name the lookup Product_ByCategoryId
    d) Select the GetByCategoryId in the List Filter and finish the wizard.
    Now the Product drop-down based on this lookup will expect a Product_parCategoryId parameter when the dropdown part is opened.

  2. 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 the Category field’s value changes, the Product field will reset, expecting you to enter a new value.
    a) Right click on the dependent Product entity field.
    b) Select New > Dependency
    c) Select the Category field.

  3. Select the lookup in the drop-down in the screen designer
    a) Open the screen section
    b) Select the Product 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 lookup Product_ByCategoryId
    d) Now go to the ParameterMappings property and click on […]
    e) You will see the Product_parCategoryId parameter.
    d) Put the category’s field name in the ColumnName, in this case refCategoryId.
    This way you tell the Product drop-down that it should use the value from the Category to filter the products.

1 Like

Note: For finishing of the filter GetByCategoryId (step 1a) must exist parameter Product_parCategoryId with UniqueIdentifier data type on the Product entity, added on the right side of the filter (as you can see on the Picture).
See more about parametres: https://origam.com/doc/display/architect/Parameters