Custom Email Tags in EspoCrm

EspoCrm is a fantastic open source crm system. The ability to customize it to your company needs is one of the best aspects. In this post, we’ll look at how to add a custom tag to the Email entity.

Background

There are many use cases that can drive this need. Our first use case was to tag sales meeting summary emails for use by sales. Once tagged, they become searchable, and reps could view a variety of examples of meeting summaries to assist them in crafting their own. This was found easier to maintain vs. the existing sales training wiki. In our case, after a typical initial customer meeting, a detailed meeting summary is written and sent, summarizing the discussion and agreed upon value proposition. An essential step in customer centric selling.

Implementation

First create a custom field in the Email entity. Go to Administration, Entity Manager, Email, Fields, Add Field. Choose Multi-Enum.

I name all our custom fields with a “C” suffix to indicate Custom, in this case “tagsC”. Add the tag values in the Labels section. I like the Display as Label option and enable it. Select any other options you want and save.

Next the field needs to be added to the Layout. While most entities in EspoCrm can have their layout customized from the GUI, the Email entity in EspoCrm is not one of those. This requires a code level change.

Espo allows this level of customization in the custom/Espo/Custom/Resources/layouts directory. Since this is our first customization of the Email entity, a subdirectory for Email needs to be set up. We have espo running in Docker. Substitute directories and owners as appropriate for your application.

cd /dockerdata/espocrm/custom/Espo/Custom/Resources/layouts
mkdir Email
chown --changes  www-data:www-data  ./Email

Next, make a copy of the desired existing layout template(s). In this case, we’ll just do the detail template.

cp /dockerdata/espocrm/application/Espo/Resources/layouts/Email/detail.json ./Email/
chown  www-data:www-data *.json

The final step is adding the field to the copied and now custom Layout json file. Edit it and add the field as follows.

[
    {
        "label":"",
        "rows":[
            [{"name":"dateSent"},{"name":"from"}],
            [false, {"name":"to"}],
            [{"name":"parent"}, {"name":"cc"}],
            [false, {"name":"bcc"}],
            [{"name":"subject","fullWidth":true}],
            [{"name":"body","fullWidth":true}],
            [{"name":"attachments"},{"name":"isHtml"}],
            [{"name":"tagsC","fullWidth":true}]
        ]
    }
]

Note the “tagsC” entry. Placement at the bottom results in the tag field at the bottom of the form.

Using

Now you can view an existing Email for example in the History for a Contact. Select it, choose Edit, and set your tag.

You can search for tagged emails from the Emails view.

Now with the first tag set up, adding others is trivial to expand to other departments such as technical support, customer service, accounting, etc.