Cloning Entity In EspoCRM

As we know EspoCRM already support four entity types (structure templates) for now:

  • Base.

  • Base Plus

  • Person.

  • Company.

But sometimes you may need to clone an existing entity including all related functionalities. For example you may want to duplicate the "Meeting" or "Call" ones, or even to duplicate custom entities definitions you made by your hand from one crm to another or in the same crm.

Let's say we want to clone the "Meeting" entity as example to a new entity names "Lesson",

- Create the new entity named "Lesson" from type "Base".

- Update Lesson controller:

path: /custom/Espo/Custom/Controllers/Lesson.php'

namespace Espo\Custom\Controllers;

use Espo\Modules\Crm\Controllers\Meeting;

class Lesson extends Meeting

- Update Lesson Repository:

Path: /custom/Espo/Custom/Repositories/Lesson.php


namespace Espo\Custom\Repositories;

use Espo\Modules\Crm\Repositories\Meeting;

class Lesson extends Meeting

- Update Lesson service file:

Path: /custom/Espo/Custom/Services/Lesson.php


namespace Espo\Custom\Services;

use Espo\Modules\Crm\Services\Meeting;

class Lesson extends Meeting

- Copy any Meeting.php files from `application` folder to `custom` folder, in our case we have these two files:


Copy them to:

/custom/Espo/Custom/SelectManagers/Lesson.php /custom/Espo/Custom/Acl/Lesson.php

NOTE: don't forgot to replace 'Meeting' words occurrence with 'Lesson'

NOTE: change the namespaces as well to

namespace Espo\Custom\Acl;

- Resources JSON files:

open this file:

- application/Espo/Modules/Crm/Resources/i18n/en_US/Meeting.json

and copy its content to this one

- /custom/Espo/Custom/Resources/i18n/en_US/Lesson.json

copy `Meeting` layout folder


Copy the following `Meeting` metadata files



custom/Espo/Custom/Resources/metadata/clientDefs/Meeting.json custom/Espo/Custom/Resources/metadata/entityDefs/Meeting.json custom/Espo/Custom/Resources/metadata/scopes/Meeting.json custom/Espo/Custom/Resources/metadata/dashlets/Meeting.json

Update Lesson scope file setting the module value to "Custom":

    "entity": true,
    "layouts": true,
    "tab": true,
    "acl": true,
    "aclPortal": "recordAllAccountContactOwnNo",
    "module": "Custom", <== update here from "Crm" to "Custom"
    "customizable": true,
    "importable": true,
    "notifications": true,
    "calendar": true,
    "activity": true,
    "object": true,
    "activityStatusList": ["Planned"],
    "historyStatusList": ["Held", "Not Held"],
    "statusField": "status"

You can find the Source Files here.

504 views0 comments

Recent Posts

See All

Espocrm custom layout for relationship

Espocrm layout system has two types of layouts Detail Layout List Layout And by default provides four layouts for every entity as following: List: used in the main list screen Small List: used in rela

©2020 by Eblasoft.