Conditional IF statements in an salesforce email template

Hi all SF guys,
Yes this is possible to have conditional IF statements in an email template.

Today I faced some issues when I was using IF statements in "HTML Email Template".

So, I found that some time its not works when you are using "HTML Email Template"  because of metadata issue.

Issue:
If you are using IF statements in HTML email template, some time its metadat in backend add some formating html and css inside of IF statements, Thats why its not working.

Solution:
Edit the email template matadata and remove all html and css which is inside your IF statement:

Note: Please use eclipse IDE or sublime text to edit email template.

Ex:
IF statements in an email template not works when email template metadata like as:
<div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;">
{!IF(Lead.vpUID__c&nbsp;=&nbsp;""<span style="font-size: 12pt;">,&nbsp;</span>"<span style="font-size: 12pt;">No"</span><span style="font-size: 12pt;">,&nbsp;</span></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><span style="font-size: 12pt;">"Yes</span><span style="font-size: 12pt;">"</span><span style="font-size: 12pt;">)}</span></div>

To make it worable please remove all strange html inside from IF statement like as:
<div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;">
{!IF(Lead.vpUID__c = "", "No", "Yes)}
</div>

After removing all these strange and useless html, Save it.
Now this will work for you :)

No comments:

Post a Comment