Email Template #if statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ategenkamp
    Junior Member
    • Mar 2021
    • 26

    Email Template #if statements

    I'm just looking for clarification on the status of #if statements in email templates. I'd like to do something like:

    Code:
    Dear {{#if Person.salutationName}}{Person.salutationName}{{else}}{Person.firstName}{{/if}} {Person.lastName},
    I thought this would work since https://docs.espocrm.com/user-guide/...mail-templates says it has Handlebars support since 5.9.0.

    I know from some posts say it will only work right on PDF templates and it does, which is great!

    I appreciate any help on the status of #if statements in email templates in 6.1.5.

    Thanks,
    Andrew
  • item
    Active Community Member
    • Mar 2017
    • 1484

    #2
    Hello,
    just see doc "Email templates also support handlebars. It's the same template system used for PDF templates with double-brace placeholders, like {{name}}"

    so look here : https://docs.espocrm.com/user-guide/printing-to-pdf/#if
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • abisbe
      Member
      • May 2021
      • 60

      #3
      So helpful!

      So let's say that I am generating the E-mail using a template from a workflow, and I have some variables there, can I pass these variables using placeholders too? Or will they only work with entity attributes?

      Thanks!

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1257

        #4
        abisbe

        Yes you can pass variables from workflow to the email template using a placeholder {$$variableName}, you need to use save formula to save the variable before sending the email.

        Good luck
        Rabii
        Rabii
        Web Dev

        Comment

        Working...