Announcement

Collapse
No announcement yet.

Connect 3 Entities, is it possible

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

  • Connect 3 Entities, is it possible

    Hello everybody!

    First of all thank you for this awesome software, it's really great to work with!

    I have a question for you.

    I have 3 Entities created through the entity manager ( which is a GREAT tool ).

    Entity 1 is connected to Entity 2

    Entity 2 is connected to Entity 3

    I'd like to create a field in Entity 1 which contains the name field of Entity 3 connected to Entity 2 which is connected to Entity 1.

    Is it possible to achieve this in any way?

    Thanks a lot!


  • #2
    yes it is possible, depending on relationships you defined, you can still define a relations between entity 1 and entity 3 and in the entity 2 you can add a formula to update entity 1 (field of entity 3) when changed.

    Comment


    • #3
      if you provide more details about the names of your entities and relationship we could help more and provide the code to do the job. welcome onboard

      Comment


      • #4
        Hello!

        Thanks for the quick answer!

        So:

        Entity 1 is called ORDERS
        Entity 2 is called CLIENTS
        Entity 3 is called BUYERS

        ORDERS is connected with a MANY TO ONE relation to CLIENTS

        CLIENTS is connected with a MANY TO MANY relation to BUYERS

        All I need is a field in the ORDER entity filled with the name of the BUYER associated with the CLIENT.

        Is this possible?

        Thanks!!!

        Graziano

        Comment


        • #5
          I can see an issue there the clients is related to buyers through a many to many relationship so in the Order entity if you add a link to represent the Buyer then the questions is which of the buyers you want to pull out of the Client (hence the client will have a list of buyers). In this case two things you can as a many to many relationship between the Order and Buyer entities and have the Buyers field available on the order and through formula when a new order if created you can update the buyers with the current buyers of the Client. Otherwise you can always set up a one to many relationship between the Buyer and Order (One Buyer has many orders) and then grab the first buyer from the Buyers on the Client and add it to the Buyer field on the order. You can use formula or Custom views / even customise a relationship on clientDefs would be possible if you have the latest version of espocrm.

          Comment


          • #6
            Sorry for the late answer!

            Thank you very much for your explanation!

            I like the solution of putting a field in the Order and filling it with a formula which read the Buyer from the Client assigned to the Order.

            How can I achieve this?

            Thank you!

            Comment


            • #7
              you can do this, create a one to many relationship between the Buyer and Order (One Buyer has many orders), display the buyer field on the detail view of the Order and use the formula below on the Order entity:

              PHP Code:
              ifThen(clientId && !buyerId,
                  
                  
              $buyerId record\findOne('Buyer''createdAt''desc''clientId='clientId);
                  
                  
              entity\setAttribute('buyerId'$buyerId);
              )
              ​ 
              Please make sure to use the correct field names (clientId is supposed to be the link id name of the client on the Order - buyerId is link id name on the Order).

              Hope this helps.

              Comment

              Working...
              X