Announcement

Collapse
No announcement yet.

How to use handlebar conditions in email templates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use handlebar conditions in email templates


    Is there a way or workaround to use handlebar conditions in normal email templates?

    Current version: 5.7.9

    Expample:
    HTML Code:
        <!-- {{#if Lead.lastName}} --> <Dear Mr. {Lead.lastName}}, <!-- {{else}} --> Dear Sir or Madam, <!-- {{/if}} -->

  • #2
    Not possible.

    Comment


    • rabii
      rabii commented
      Editing a comment
      Hi @Yuri

      It says that this might be possible in the email template documentation https://docs.espocrm.com/user-guide/...lebars-support though it is mentioned that it is only experimental.

      is there any chance this could be implemented in future hence they are using the same template system ?

      Thanks

  • #3
    Still not working, at least not working with {{#ifEqual ...}} ... a pity!
    Regards

    Comment


    • yuri
      yuri commented
      Editing a comment
      It works. Please do not give misleading information. The parent field should be not empty (mentioned in the docs Rabii refered). You can use helpers with attributes of the parent-entity as arguments.
      Last edited by yuri; 05-19-2022, 06:24 PM.

    • agri
      agri commented
      Editing a comment
      @Yuri
      First of all I must appologize, I did not *intend* to give misleading information! Still, I don't get it ...
      "You can use helpers with attributes of the parent-entity as arguments." -> Could you please give an example?
      I tried
      {{#ifEqual Person.salutationName "Herr"}}Sehr geehrter {Person.salutationName} {Person.name}{{/ifEqual}}
      {{#ifEqual Person.salutationName "Frau"}}Sehr geehrte {Person.salutationName} {Person.name}{{/ifEqual}}
      {{#ifEqual Person.salutationName "Dr"}}. Guten Tag {Person.salutationName} {Person.name}{{/ifEqual}}
      If e.g. salutationName is "Herr", this will result in *three* lines like
      "Sehr geehrter Herr firstname lastname
      Sehr geehrte Frau firstname lastname
      Guten Tag Dr. firstname lastname"
      instead of only the forst one. I also tried {{#ifEqual ... 'Herr'}} and {{#ifEqual ... Herr}} -> same result. This gave me the impression, that it does NOT work.
      Perhaps I don't get, which is the parent-entity of an Email template, where to find the "parent field" and what to fill in there.
      Regards
Working...
X