Announcement

Collapse
No announcement yet.

Email Template Condition

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

  • Email Template Condition

    Hello,

    I have an email template that gets values as 1 and 0, which are taken from Customer's profile. However, when I try to write a condition like it was mentioned in the documentation, to be like that {{#if Contact.TaxFlag}}Yes{{else}}No{{/if}}

    However, it gives No anyway, even if the answer was Yes.

    Also, I tried to use ifEqual like that:

    {{#ifEqual Contact.TaxFlag 1 }} Yes{{else}}No{{/ifEqual}}

    and it gave the same result..

    Is it possible to code something in Javascript?.. or what could solve this?

    Please, can you help me find a solution for this issue?? As I researched everywhere, and there was no answer for that...Please any way to solve this, will be very appreciated.

    Thanks in advance!

  • #2
    instead of 1 and 0, try to use true and false. Time ago I solved that problem with PDF template (what works normally the same in email template) here: https://forum.espocrm.com/forum/gene...0250#post50250

    Comment


    • #3
      Hello,

      The problem is that I get only 1 or nothing (no zero), I've read about handlebars, and I've tried to check the default box for the entity field but still this issue occurs, and the if statement is not working properly.

      How can I make the default value 0 if not checked?

      It would be great to find a solution that will be solved using espocrm interface, because I have limited access to the code currently.

      Many Thanks!

      Comment


      • #4
        try this

        Code:
        {{#ifEqual taxFlag true}} Yes {{else}} No {{/ifEqual}}
        Usually when using conditions in email template you don't need to mention entity like (Contact.TaxFlag) instead just use the field directly.

        Cheers
        Rabii
        Web Dev

        Comment


        • jd13579
          jd13579 commented
          Editing a comment
          I tried, but it didn't work, I get only 1 or null values.

        • esforim
          esforim commented
          Editing a comment
          Some of these tag get issue if you don't copy/paste it using the code view (click <> button).

          Also try checking your field name again and see if it all correct, also try different variation and see if it behave in any expected way. For example; using use

          {{#ifEqual taxFlag false}} Yes1 {{else}} No1 {{/ifEqual}}
          {{#ifEqual taxFlag true}} Yes2 {{else}} No2 {{/ifEqual}}
          {{#ifEqual taxFlag 1}} Yes3 {{else}} No3 {{/ifEqual}}
          {{#ifEqual taxFlag 0}} Yes3 {{else}} No3 {{/ifEqual}}
      Working...
      X