Got it work now. I just changed the Formating a bit, and now it works. Very strange...
How to use an if-statement in SalesForce E-Mail Template
-
16-01-2022 - |
Pregunta
I'm trying to add a if-Statement to my E-Mailtemplate (Type: HTML). I used the following code:
{!if(Lead.LastName="", "1", "2")}
My Output is just nothing :/
Does anyone know how to do it right?
Solución 2
Otros consejos
I believe the more complex logic like conditionally rendering data is not available in straightforward emails. IF
, BLANKVALUE
etc functions don't work, instead there's something similar to Dear {!Lead.LastName, 'Sir or Madam'}
that's supposed to be fallback scenario if the field was empty.
If you're not too afraid - make a visualforce email template instead?
<messaging:emailTemplate subject="Hello StackOverflow" recipientType="User" relatedToType="Lead">
<messaging:HtmlEmailBody >
<p>Related To: {!relatedTo.Name}, {!relatedTo.LeadSource}</p>
<p>Recipient: {!recipient.Username}</p>
<p>{!IF(ISBLANK(relatedTo.LeadSource), '1', '2')}</p>
</messaging:HtmlEmailBody>
</messaging:emailTemplate>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow