How to add a filter to an association field


I have an edit screen (entity Company) that one of the fields is a association with the City entity. When the user clicks this field to select a City, I would like to open the City Browser with a filter (only cities in a region). How can I define this filter?

Thank you,



Use query params & query filter
On browse screen of City entity:

<collectionDatasource id="citiesDs" class="com.sample.entity.City" view="browse">
    <![CDATA[select e from <prefix>$City e ]]>
            <c> = :param$region</c>

Use the PickerField or LookupPikerField for City field.
Modify lookup action on this screen component and add code in screen Controller

protected PickerField cityField;
public void init(Map<String, Object> params) {
    RegionEntity region =<same code>
    PickerField.LookupAction action = cityField.getActionNN("lookup");
    action.setLookupScreenParams("region", region) 
1 Like

Hello Kirill,

Thank you a lot!


1 Like