Using Account to Account Relationships with a single layout field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DaBootO
    Junior Member
    • Jul 2022
    • 4

    Using Account to Account Relationships with a single layout field

    Hello together,

    I am very new to espoCRM but I really like the modularity! I am currently on v7.1.9 without extensions, self-hosted.
    Now I am having problems with implementing a relationship between Account Entitites. Let me explain what I'd like to accomplish:

    Situation:
    Let's say we have Account1, Account2 and Account3.
    I would like to have a field (Link Multiple) to define and list all its competitors.

    e.g.
    Account1 is a competitor of Account2.
    Account3 is a competitor of Account2.
    -> Field contents of Account1: "Account2"
    -> Field contents of Account2: "Account1", "Account3"
    -> Field contents of Account3: "Account 2"

    Problem:
    I tried using the many-to-many relationship.
    This "works" BUT I will need 2 fields in the Account.
    1. to show me the competitors I have definded on this account
    2. to show me all the accounts which have set this account as their competitor in their respective field 1

    Goal:
    I'd like to have a single field which automatically syncs over all the other Accounts I have set. If I set Account2 as a competitor on the page of Account1 I'd like to switch over to Account2 and the Field has Account1 automatically synced over/appended.

    Is this possible with the "base" functionality? I had the idea of using hooks to update/add the field contents but I wanted to ask here before I go down that rabbit hole.

    If there are any question or if my explanation wasn't clear enough please feel free to comment down below.

    Regards
    DaBootO
    Last edited by DaBootO; 07-31-2022, 09:41 AM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    Welcome to the forum. I think that the better/more-proper model is to have a separate entity that connects multiple competitors.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • DaBootO
      Junior Member
      • Jul 2022
      • 4

      #3
      yuri I tried your recommendation. Thanks for commenting!
      I created an entity called "Competitors". In the "Account" entity I created a many-to-many relationship with the "Competitor" entity as the foreign entity. (I thought this might be the best way, as I don't want to use another tab "Competitors" to save this information) The problem is, that - clearly - the field now only accepts entities of type competitor as input.

      Am I using the many-to-many relationship correctly? I tried learning more about this data-model online and it seems that of the 3 models (one-to-one, one-to-many/many-to-one and many-to-many) the many-to-many relationship is the most suitable for my needed application. Although I see one problem: Those data-models are used to connect information from two or more tables, but I am trying to connect information inside one table (account table in the SQL DB).

      Could you elaborate on what you meant? I suppose I did not really understand what you recommended. (Sorry I am pretty new to this world)

      Regards
      Last edited by DaBootO; 07-31-2022, 03:18 PM.

      Comment

      Working...