Any way to use more fields than Id and name from multiple link n:n relationship

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1603

    Any way to use more fields than Id and name from multiple link n:n relationship

    As the subject already tells, I am looking for a possibility to get more fields from a n:n relationship into the related entities.

    I would like to work with some other fields, which is possible for n:1 relationships but not for n:n. I see in the database, there are only saved Id and the ID of the record`s name, but nothing usable for varchar fields.

    Maybe I did not understand the reason for this, but it would be great to have this possibility. Does anybody have an idea?
  • telecastg
    Active Community Member
    • Jun 2018
    • 907

    #2
    Hello shalmaxb

    In many-to-many relationships, Espo creates a "middle table" that links the entities.

    Click image for larger version  Name:	Screenshot 2022-12-29 091021.png Views:	0 Size:	29.3 KB ID:	86669

    For example, if you want to pull the "role" field from the account_contact middle table, you would need to write a query like this:

    Code:
    Select account_contact.role
    From account
    Inner Join account_contact
    On account_contact.account_id = account.id
    Inner Join contact
    On contact.id = account_contact.contact_id​
    @eymen-elkum​ extension allows you to add and render middle table fields as tabular entries.
    https://www.eblasoft.com.tr/espocrm-...le-inline-form
    Last edited by telecastg; 12-30-2022, 11:04 PM.

    Comment

    • shalmaxb
      Senior Member
      • Mar 2015
      • 1603

      #3
      I guessed something like that, though I never did it. I own the extension from Eymen, but in lack of a manual I never really fully understood that possibility. I will try to get it to work.

      Comment

      • esforim
        Active Community Member
        • Jan 2020
        • 2204

        #4
        You may have missed this article in the product page: https://www.eblasoft.com.tr/post/lin...o-many-to-many

        Comment


        • shalmaxb
          shalmaxb commented
          Editing a comment
          Thank you, I have seen that but unfortunately it is very difficult to understand. The main subject I do understand: you will have to create the two related entities in the GUI without creating the relationship there. You will have to create the middle table by creating another entity, which will serve as the "connector" between the two. So far so good.
          Then I should choose the field to connect. But where and which field from where? In the middle table? In one or both of the former created entities. When I look into the dropdown for the fields available to be connected, those are different in both of the entities and I could not figure out, what and where to choose. It`s hard, when you will have to guess and it is not clear, if I would really be able to use the extra fields for further utilization.

        • esforim
          esforim commented
          Editing a comment
          I don't have the Extensions so I can't experiment. I can only suggest to give it a try with the tutorial, then try with your own entity, then get some support from The Man himself.
      Working...