How to use #if on email template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wolfysoft
    Junior Member
    • Sep 2021
    • 8

    How to use #if on email template

    I using Hook for send email and it work now.

    But I can't use #if condition on EmailTemplate

    I tried

    {{#ifEqual showPhone 'Yes'}}
    {SendEmailToClient.companyName}
    {{else}}
    {SendEmailToClient.showPhone}
    {{/ifEqual}}

    showPhone is enum-field

    and I receive this on email

    {{#ifEqual showPhone 'Yes'}} Ekko Lab AI Co.,Ltd. {{else}} Yes {{/ifEqual}}

  • shalmaxb
    Senior Member
    • Mar 2015
    • 1602

    #2
    Did you insert the #if condition in the code view? And you have to comment out the code (<!-- xxx -->).
    Another mistake could be "yes". I guess it is a bool field? Then you have to use true/false (yes/no).
    And it should be ifEquals, with an "s" at the end.
    And I also think, you don`t even need ifEquals in this case, only if should do it.

    If you want more insight, how this works, perhaps this could help: https://handlebarsjs.com/guide/
    Last edited by shalmaxb; 09-10-2021, 07:18 AM.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      You need to pass 'parent' => $entity with email template params to make htmlizer working. I recommend to debug code of the method you invoke to find out the problem.

      p.s. this has nothing to to extensions. It's out-of-the-box (experimental) feature.
      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

      Working...