Programmatically add filter to screen

Is there a way to add filter search conditions from the code to the screen without using the “Add Search Conditions” on the actual screen?

Unfortunately, the generic filter component doesn’t have a convenient API. However, you can to work with it programmatically if you just assign a proper XML, for example:

    @Inject
    private Filter filter;
    @Inject
    private Metadata metadata;
    @Inject
    private UserSessionSource userSessionSource;

    @Subscribe("addCondition")
    public void onAddConditionClick(Button.ClickEvent event) {
        FilterEntity filterEntity = metadata.create(FilterEntity.class);
        filterEntity.setXml(
                "<filter>\n" +
                "  <and>\n" +
                "    <c name=\"date\" class=\"java.time.LocalDateTime\" operatorType=\"EQUAL\" width=\"1\" type=\"PROPERTY\"><![CDATA[e.date = :component$filter.date02956]]>\n" +
                "      <param name=\"component$filter.date02956\" javaClass=\"java.time.LocalDateTime\">NULL</param>\n" +
                "    </c>\n" +
                "  </and>\n" +
                "</filter>"
        );
        filterEntity.setComponentId(ComponentsHelper.getFilterComponentPath(filter));
        filterEntity.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
        filterEntity.setName("");
        filter.setFilterEntity(filterEntity);
    }

The XML for conditions can be copied from an existing filter: create a filter at runtime, then go to Administration -> Entity Inspector, select “Filter (sec$Filter)” entity, find a row corresponding to your filter and copy its XML field content.

ok, thanks. I will try