How do I add a "Type" field in Email Templates?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nocstaff@urbancom.net
    Member
    • Jul 2025
    • 73

    #1

    How do I add a "Type" field in Email Templates?

    Our SMS templates are all made in email templates. I'm trying to add a way to automatically add opt-out language as a footer of every sms template we create automatically, and my plan was to do that by adding a custom type that lets you choose between email and sms, and when sms is chosen it automatically appends the opt-out language I want at the end of a template. The problem I'm having is I can't add that type field. The UI won't let me even touch the email template entity, and I tried to add it to the back end by adding this newly made file

    metadata/entityDefs/EmailTemplate.json

    {
    "fields": {
    "templateType": {
    "type": "enum",
    "options": ["Email", "SMS"],
    "default": "Email"
    }
    }
    }

    and in layouts I made an EmailTemplate folder with a detail.json and edit.json file with the following code:

    [
    ["name", "templateType"],
    ["category"],
    ["subject"],
    ["body"]
    ]

    But this did not work.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9419

    #2
    It would be helpful if you provided full file paths. Not clear whether you created correct ones.

    custom/Espo/Custom/Resources/metadata/entityDefs/EmailTemplate.json
    custom/Espo/Custom/Resources/layouts/EmailTemplate/detail.json

    Use cTemplateType name instead ('c' prefix).

    Then, rebuild.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • nocstaff@urbancom.net
      Member
      • Jul 2025
      • 73

      #3
      Sorry about that, I'll be sure to include full file paths. I can confirm those were the full paths I used.

      I tried that fix, but now I cannot open/create any email templates after I rebuilt. I try to click on the existing templates or click on the create a new template button and nothing happens. It stays that way until I delete detail.json specifically and then rebuild. Do you know why this may be happening?

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9419

        #4
        Use the default Email Template's detail.json file and copy it to the custom. Add the needed field there. Make sure it's a valid JSON.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • nocstaff@urbancom.net
          Member
          • Jul 2025
          • 73

          #5
          That did the trick. Thank you so much!

          Comment

          Working...