Alternative implentation to relatedEntities component

Hello,
it is very comfortable to use the relatedEntities Element to show the releated Entities in a new list. However the filter in the releated list is initialized with an “In-Query” instead a “Related-To-Query”. E.g. order.id in (1,2,3,…) instead of order.customer = … The “In-Query” doesnt work when the list of Ids is very large (>2000).

  • How is the relatedEntities function implemented? I debugged the page containing the related list and in the init method i saw no special parameters transferred to the page.
  • How would you suggest to implement it as a "Related-To-Query"? Transfer e.g. the customer as parameter to the orders page? Or could the relatedEntities component be adapted?

Hi Stefan,

You could adapt existing RelatedEntities component by extending functionality of WebRelatedEntities component.

RelatedAction opens browse screen for entity and adds to Filter on the screen one hidden condition: IN :collectionOfRelatedInstances. RelatedAction creates special filter condition in the getRelatedEntitiesFilterXml method and after browse screen opening applies filter with this hidden condition. You can try to extend WebRelatedEntities component and override addNavigationAction method to create custom instance of RelatedAction with changed logic of creation of filter condition.

If such an extension is hard to implement then you can always create custom screen with collectionDatasource that will use query parameter to filter records if parameter is set. Optional query filter is described here: [url=https://doc.cuba-platform.com/manual-6.2/datasource_query_filter.html]https://doc.cuba-platform.com/manual-6.2/datasource_query_filter.html[/url]. You can call this custom screen either from a custom button or from an extended RelatedAction to use it only for heavy lists of entities.

We will try to improve performance of RelatedEntities and use normal query instead of IN if it is possible for concrete relationship. This issue is not scheduled for any release yet, but we will try to provide a fix in the next minor release, that we plan to roll out.

Thanks for your reply. I currently solved it by extending the datas ource with a query filter and looking forward the next release :-).

According to changelog in release 6.3.3 the ReleatedEntities component was adapted (PL-7719).

For a 1:n relationship the filter in the related entities screen contains now only the id of the source entity, which is very good. But for a n:m releationship the filter still contains the “IN condition” with all target ids. I this a bug or implemented by intention?

Hi,
for now RelatedEntities will use slow query for Many-To-Many relations if both sides of relation are Owning sides.

We will release improvement for this case later in the next bug fix version of 6.3 Release.

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-7719