OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions Create Datagrid Filter for ManyToMany field

This topic contains 2 replies, has 3 voices, and was last updated by Hiro Hiro 6 years ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #28177

    I need to add Datagrid filter to enable to list Entities having the filter value in ManyToMany field.

    What I have tried:

    As the comment says, I don’t seem to be able to expect DQL to return the parent table data even if the child data does not exist by using LEFT JOIN (Maybe because the child table gets multiple records?).

    Is there a workaround for this situation, like, is there a way to apply subquery using EXISTS only if the filter “ItemCode” is used somehow? If not, is there any timing we can amend the DQL right before the query execution to chuck in the subquery after checking if the filter is ItemCode by creating custom Listener Class or something?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #28178

    Alexandr Smaga


    Not sure that I got your issue well. How you expects this filter to work ?
    Left join will return entity A event if it will have zero associated B entities.
    And if it will have multiple B entities associated, then multiple rows for same entity A will be in results.
    I suggest you are looking for left join with additional WITH condition, something like this

    It’s possible to apply any additional restrictions on query builder in event listeners on oro_datagrid.datagrid.build.after.YOUR_GRID_NAME event.


    Thank you for the reply.

    As you mentioned, Left Join seems to return Entity A as I have noticed that the issue is not replicated at another development environment. And I think only the difference between the environments is database data.

    Hope there is just missing data going on.

Viewing 2 replies - 1 through 2 (of 2 total)

The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No