3

I am trying to put a line break inside of an IF statement within a plain text email template.

The template is like this:

Hi {!Receiving_User.FirstName}, 

{!IF(Receiving_User.Profile = "Desired Profile","Text will go here if the profile matches the desired profile. Want this line to be a new paragraph", "")}

I was accomplishing this with multiple IF statements on each line but I have multiple statements like this and if the desired profile does not match then each IF statement puts a blank line into the email and I have 8 of them so the email can end up looking like:

Hi User,







Text from first matching statement here.

I have tried putting a \n in the text and a BR() and also tried creating a Custom Label called NewLine with a value of - and then putting SUBSTITUTE($Label.NewLine, "-", "") in but not sure I have that in the code properly to determine if that will work. I tried

{!IF(Receiving_User.Profile = "Desired Profile","Text will go here if the profile matches the desired profile." +SUBSTITUTE($Label.NewLine, "-", "")+ "I Want this line to be a new paragraph", "")}
1

Short answer: you can't. Normal plain text templates are incredibly limited in what they support; they only support a small subset of all the functions in the Formula help topic.

Instead, use a Visualforce email:

<messaging:emailTemplate subject="Test" recipientType="User" >
<messaging:plainTextEmailBody >
<apex:outputText rendered="{!recipient.Profile.Name='Desired Profile'}">
Text will go here if the profile matches the desired profile.

I Want this line to be a new paragraph
</apex:outputText>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
0

I had the same issue and found a way to do this (probably not perfect in code terms but it worked). Do not break line between all your if statement, instead enter a break line in your iftrue result right after the "

Your Example:

Hi {!Receiving_User.FirstName}, 

{!IF(Receiving_User.Profile = "Desired Profile","

Text will go here if the profile matches the desired profile. Want this line to be a new paragraph",

"")}{!IF(Receiving_User.Profile...

Enter your breakline before your "Iftrue" text so each time your statement is true it will break a line, enter all your IF statements inline so no further break line will be created

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.