1

I need to display a message based on a condition which has to be formatted with bold style, add line breaks, etc. Using HTML markup inside IF condition is not working in HTML email templates.

For example,

{!IF(customObject.customField__c = 'Expected Value', '<BR><UL><LI>Item1</LI><LI>Item2</LI></UL>', '')}

However, the same IF condition works if the message to be displayed is plain text.

Do you have any suggestions on this?

2

For HTML template, use div and set the style display conditionally

<div style="display: {!IF(customObject.customField__c = 'Expected Value', '' , 'none')}">
<BR><UL><LI>Item1</LI><LI>Item2</LI></UL>
</div>

Alternative solution for visualforce email template

try with apex:ouptputpanel and use rendered attribute to show the content

<apex:outputpanel rendered="{!customObject.customField__c = 'Expected Value'}">
<BR><UL><LI>Item1</LI><LI>Item2</LI></UL>
</apex:outputpanel>
  • Thanks for your quick answer! Is there a way to do this in HTML email template? – Vijay Prakash Oct 12 '16 at 7:04
  • @VijayPrakash check the updated answer – Ratan Paul Oct 12 '16 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.