Announcement

Collapse
No announcement yet.

Cascading selects for Parent - child relationships between entities

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cascading selects for Parent - child relationships between entities

    Hi all,

    I have 4 entities:
    1. Volunteer
    2. Region
    3. District (is child of region)
    4. Municipality (is child of district)

    I have added the region, district and municipality to the volunteer as relationships (one-on-one).
    When I have selected the region in the volunteer, I wish to then only show the districts in that region when I select the district entity.
    Similarly when I select the municipality, I only want to show only those that are in that district.

    I know this can be done when using Enums and conditional logic, but the Enums are just flat text, not entities. Is it also possible to make a cascading select on entities with a parent-child relationship?

    I want to have this behavior, because there can be duplicate names of municipalities. So if I don't have the cascading selects, but only one relationship with Municipality, it will be more error prone to select the right municipality. Also the cascading behavior will greatly reduce the number of entities to select from.

    I hope someone has been able to realize this behavior.

  • #2
    Hi,
    You need to add such filters via code, by creating your custom view https://docs.espocrm.com/development/custom-views/.
    For example, investigate how it works fo Opportunity. In Opportunity, if you have selected Account and you want to select Contact, you will view a list of contacts that related to selected Account (see screenshot).
    Investigate how this logic is set for Opportunity:
    1. https://github.com/espocrm/espocrm/b...nity.json#L131.
    2. https://github.com/espocrm/espocrm/b...ntacts.js#L175.

    Note, to customize your own view with safety way, you need to add your custom view code into the /client/custom/... directory.

    Comment

    Working...
    X