Bug with related entities

Hi all,

Using the related entities action does not work if a user has saved a standard filter configuration for the target browse screen in JMix 1.6.1.
Fo example, going from an employee screen to the related companies, JMix loads the related companies for the employees. Then it creates a runtime filter configuration with the companies. After that, the configuration is set in the companies browse screen. As a last step, screen.show() is called which will load user settings if the settingsFacet is present. By that, the runtime filter configuration will get overwritten by the user’s standard filter and no companies are filtered.

I think it could be solved by adding a few lines to the RelatedAction.java. I did this as a workaround but had to overwrite several classes related to layout loading etc. to insert my adjusted RelatedAction.

    Screen screen = builder.build();

    screenInitializer.initScreen(screen);

    ScreenSettingsFacet screenSettingsFacet = ((ScreenSettingsFacet)screen.getWindow().getFacet("settingsFacet"));
    if (screenSettingsFacet != null){
        screenSettingsFacet.excludeComponentIds("filter");
    }

    screen.show();

Obviously, not all filters on all target screens will be of the id “filter” so maybe a little bit of additional parsing may be necessary.

Hello!

It seems like a bug, I created an issue: Runtime filter configuration is replaced by configuration form settings when RelatedEntities opens a screen · Issue #3989 · jmix-framework/jmix · GitHub

As another workaround, you can create a specific screen for related entities and set it to the RelatedAction (RelatedAction :: Jmix Documentation).

Thanks for creating the issue and the workaround, we will try it out!