how to build a link between 2 custom-entities?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ctheuring
    Senior Member
    • Oct 2022
    • 138

    how to build a link between 2 custom-entities?

    Hello
    I'm new on EspoCRM - but with more than 25 years of expertise in CRM and Databases (FireBird and others).
    I am doing to change a (long living) CRM-system to EspoCRM.
    I build 2 new entites - FIRMEN (like your accout) also with typ account and PERSONEN (like your contacts) also with type contacts.
    FIRMEN (companies) has a integer-ID-field FIRMENID, and PERSONEN (employees) has a (to be linked) integer-ID-field FIRMEN_ID. This meens, that all employees in the PERSONEN-entity with the same integer in its FIRMEN_ID-field belonged to the company with the same ID in its FIRMENID-field.
    I imported some records to this new entities.
    ​How can I make this relationship?
    How can I show a list of employees in the FIRMEN-panel?
    Would it be wise to change the relationship (later) to the EspoCRM-standard (by SQL-updating the table-fields ID) ?
    Thanks for help

    Christoph Theuring
  • telecastg
    Active Community Member
    • Jun 2018
    • 907

    #2
    I suggest that you start by reading the developer documentation, in order to get familiar with Espo.

    Index - EspoCRM Documentation

    One of the best features of Espo is the ability by users to make pretty extensive customizations without having to dig into the code base Entity Manager - EspoCRM Documentation​ , but even if you need to do some coding, the application is easy to customize.

    Espo is a one page application brilliantly developed using a javascript (Backbone) https://backbonejs.org/#Model-Collections front end (highly enhanced, but still using the same basic principles) and a php backend. https://docs.espocrm.com/development/orm/#join

    Some of these postings might also help get you started:

    Video Tutorials - let me know what do you think - EspoCRM Open Source Community Forum

    Learning EspoCRM and Design - EspoCRM Open Source Community Forum

    Difference between one-to-one left and right relationships - EspoCRM Open Source Community Forum

    Reference: Espo GUI - script map guide, where can I change something ? - EspoCRM Open Source Community Forum

    As for your specific question, Espo implements the One-to-Many realtionship by having a field in the "many" table named {entity_id} so for example if a Contact entity is related to an Account entity, the contact table will have a field account_id (table names are all small caps formatted as table-name while ORM references are named using camelCase notation so table-name would be tableName.

    In regards to the record ID, I suggest that you let Espo generate these alphanumeric strings, since starting in verion 7.2 Espos uses "strict field validation" and one of the rules for record ids is that they meet a specific pattern.​

    Good luck !
    Last edited by telecastg; 10-26-2022, 10:34 PM. Reason: added references to Backbone and Espo's ORM

    Comment


    • esforim
      esforim commented
      Editing a comment
      Oh hi there, the thread made the "Welcome to EspoCRM list".

      Welcome Christoph, if you have the technical skill you are always welcome in my book. People like me with no coding skill and no intention to dive deep into it rely on your expertise.
  • emillod
    Active Community Member
    • Apr 2017
    • 1405

    #3
    telecastg is right You should create new entities, link them together and use id's. I'm not sure which crm you used before, but many of them support id's in relations and it can be imported. You can add bottom panel which will display employees. Here you have short tutorial: https://youtu.be/9LdulhONDkI

    One word from me - plan fields and entities wisely

    Comment

    • ctheuring
      Senior Member
      • Oct 2022
      • 138

      #4
      Thanks for hints.
      @telecastg: I start to read the documentations.
      @emilod: The "old" CRM uses ids in relations. They were build with a before-insert-trigger "select max(id) + 1 from table table" - so the are big integer.
      ... And I'm wisely with tables and fields - not always with the strong roules of the 3rd step of normal form ... because I used FireBird with the extraordinary function of computed-by-fields (the field contains no a value instead a select - possible also to other tables).
      But still my question: HOW to link the new entities together? Is it necessary to set the to-be-linked field as primary?
      Is ist possible to do it with the UI oder must I linked them together with a database-tool?

      Christoph

      Comment

      • shalmaxb
        Senior Member
        • Mar 2015
        • 1603

        #5
        You can build all this from the Administrator interface. There you create new entities, set all the fields in a vast variation of field-types, create your layout and - this for the important part of your question - all the relationships between the entities. No need to dive into database or any workaround with database tools. Abolutely not necessary and I would use such tools only after having understood completely how espoCRM works.

        What emillod ment by "wisely using fields etc." is, that when construcing your entities think thoroughly, what perhaps could come in future. Give all your field names, that later would not cause difficulties, think about, what you put in one entity or what should be better put into another entity. Keep the entities as small as possible. And all that stuff, that you should pay attention to, when creating a database. It is not easy and one makes errors, but espoCRm is not too difficult and when understood it is not far from creating miracles without coding.

        I am not a developer, but I understand a bit of the things you need for espoCRM. And even so I created an app, that without espoCRM I never would have been able to create. Additional to the comprehensive framework, that espoCRM is, you will have here in the forum a lot of help, friendly people with skills an dedication.
        If you search the forum, one recommendation: Search in Google with your problem and keyword espoCRM, you will get the best result that way. The search function of the forum is not so useful.

        Comment

        Working...