Cannot copy customized entities completely to new installation

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • shalmaxb
    replied
    Hi, without having had the profund knowledge of how the interaction between core entities and customization works, I guessed something like what you explained. Strangely, when I packed the customized core entities in the same way like the custom entities, by installing these I had for a result the customized core entity, with all fields and also present in the layout, only not positioned. The custom fields where available on the right side, where all fields are available for placing in the layout. Even without adding the custom fields in a seperate file.

    Leave a comment:


  • telecastg
    replied
    It is possible to customize a core entity through an extension and keep those customizations in a module namespace, but to display the custom fields you will have to add them through the Layout Manager.

    The reason for this is that the Layout Manager actually creates a layout file under the "Custom" namespace, which is the namespace that triumphs over any other namespace when there are "conflicting" instructions.

    In other words: a layout definition in the "Custom" namespace will override any layout definitions for the same entity at other namespaces.

    This issue is not a problem with entityDefs, where it is possible to have two files for the same entity at different namespaces and Espo will combine the contents of both files, or with clientDefs, where you can add panels without overriding other clientdefs for the same entity through the use of the "__APPEND__" keyword, but this ability, unfortunately, is not available for layouts at least as far as I know

    Here's how I customized "Contact" for an extension that I am developing to communicate with anyone using Telegram (send and receive messages) through Espo.

    For this extension is was necessary to add two custom fields to "Contact": "telegramUserId" and "telegramChatId" so I created a custom entityDefs file for Contact under the extension's namespace like this: (NOTE: per the link provided by emillod the path definition for extensions will change as of Espo 6.2 but the idea remains the same)

    application/Espo/Modules/Telegram/Resources/metadata/entityDefs/Contact.json
    Code:
    {
        "fields": {
            "telegramUserId" : {
                "type": "varchar",
                "required": false,
                "trim": true,
                "default": null,
                "maxLength": null,
                "isCustom": true
            },
            "telegramChatId" : {
                "type": "varchar",
                "required": false,
                "trim": true,
                "default": null,
                "maxLength": null,
                "isCustom": true
            }
        }
    }
    After clearing cache and rebuilding, both fields appear available at the Layout Manager so i can add them to my detail or list displays as I want.

    As additional but relevant information since you are planning to have several extensions running together in your installation, is to understand the way Espo handles conflicting instructions for the same entity at various namespaces. For example to decide which clientDefs file to use, to determine the panels to display, when there are two files for the same entity defined in different namespaces without the use of the keyword "__APPEND__".

    In the case above, Espo will use the "order" value in the extension's module.json file to determine which namespace has higher hierarchy.

    For example, the Crm module has an "order" value of 10, (see application/Espo/Modules/Crm/Resources/module.json) and for in my extension in progress I want it to be more relevant so I will give it a higher "order" value like this:
    application/Espo/Modules/Telegram/Resources/module.json
    Code:
    {
        "order": 30
    }
    Last edited by telecastg; 07-26-2021, 06:38 PM.

    Leave a comment:


  • shalmaxb
    replied
    I tried to clone one of the core entities, without success. So far it is possible to deploy customized core entities only by copying from the custom folder to the other custom folder.

    Leave a comment:


  • shalmaxb
    replied
    Yes, layout is added. I think, meanwhile I may have a solution. Eymen Elkum described cloning of entities here: https://www.eblasoft.com.tr/post/clo...ity-in-espocrm

    I noticed, that in customized core entities there are only the files of the customization present, as for example the layout. But there is nothing in Controllers, Entities etc. folders. These files you can find in the folder application/Espo/Modules/Crm.
    I did not test yet, but I guess, in case of customized entities to make installable, you will have to combine the files from the custom folder with those from the Crm folder.
    I am gonna test that tomorrow.

    Leave a comment:


  • emillod
    replied
    Did you add layout for those entities in your extension?

    Leave a comment:


  • Cannot copy customized entities completely to new installation

    In my app I use several custom entities, which I converted into extensions to be able to deploy them, where necessary.
    The entities Documents and Contacts I also customized with several extra fields, relationships, layouts and formulas.
    I tried to convert them into extensions as well, but with the core entities it seems not to work as with completely new custom entities. When I install the customized contacts for example, I can see all custom fields in the entity manager, but they are not in the layout. Although these fields are available, but not positioned yet.
    Is this a default behavior, that you cannot convert customized core entities to extensions? Is there a different approach to convert these into extensions? Or do I have to copy these customized entities from custom folder to custom folder?
Working...