conditional formula in email-template does not work as intended

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1616

    conditional formula in email-template does not work as intended

    I would like to display a salutation in Email, depending on values of the salutationName field in leads.
    I have three values in salutationName: null, 'Herr' and 'Frau'. Depending on the value I want to display the salutation term, which is generated in another field named "briefanrede", as:
    null = 'Guten Tag', Herr = 'Sehr geehrter Herr' und Frau = 'Sehr geehrte Frau'.
    My ifEqual condition is this

    Code:
    {{#ifEqual salutationName ''}}Guten Tag,{{else}}{Lead.cBriefanrede} {Lead.lastName}{{/ifEqual}}
    It works on null, displaying "Guten Tag", but in the other cases, the null value is still present, displaying "Guten TagSehr geehrter Herr"
  • yuri
    Member
    • Mar 2014
    • 8552

    #2
    I could not reproduce the issue you described. But you need to use {{#unless salutationName}} instead, as ifEqual requires value types be the same.
    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

    • shalmaxb
      Senior Member
      • Mar 2015
      • 1616

      #3
      What I see now is very strange.

      The Email comes in, when sent automatically after creating lead, like first screenshot, if sent manually with the same template sent manually from the created lead:
      Last edited by shalmaxb; 09-07-2024, 10:06 AM.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8552

        #4
        Click image for larger version

Name:	image.png
Views:	82
Size:	41.3 KB
ID:	110053

        This is not correct. Placeholders cannot be used in Handlebars helpers.
        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

        • shalmaxb
          Senior Member
          • Mar 2015
          • 1616

          #5
          I do not get, how I would have to tag it, if I want "Guten Tag" if salutaionName is null and the other form, when salutationName has a value.
          And why does it work, when Email is manually sent?

          I changed the condition, but always displaying the tag in the automatically sent mail, manually sent not.

          Code:
          {{#unless cBriefanrede}}Guten Tag{{else}}{Lead.cBriefanrede} {Lead.lastName}{{/unless}},
          Last edited by shalmaxb; 09-07-2024, 10:36 AM.

          Comment

          • yuri
            Member
            • Mar 2014
            • 8552

            #6
            You could be because automatic emails do not have a parent. https://docs.espocrm.com/user-guide/...lebars-support
            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


            • shalmaxb
              shalmaxb commented
              Editing a comment
              Thank you, I understand.
          Working...