function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BenPBenP 

If statement in plain text VF email template

I have a plain text VF email template that I'm working on.  It needs to be plain text so that the user can add some information before sending.

I'm attempting to show one address if the account is a person account and another if it's a standard account. 

With the code below I'm getting "syntax error", not very descriptive.  Any ideas?

<messaging:emailTemplate subject="RMA Request" recipientType="User" relatedToType="Case" >
<messaging:plainTextEmailBody >

Returning From:
 
Account Number - {!relatedto.Account.Customer_Number__c}
Name - {!relatedto.Contact.Name}
Address - {!IF(relatedTo.Account.IsPersonAccount, {!relatedto.Account.PersonShippingStreet}, {relatedto.Account.ShippingStreet})}



Phone - {!relatedto.Contact.Phone}
Email - {!relatedto.Contact.Email}


</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Best Answer chosen by BenP
kaustav goswamikaustav goswami
It might be an issue with the brackets. Try this.

<messaging:emailTemplate subject="RMA Request" recipientType="User" relatedToType="Case" >
<messaging:plainTextEmailBody >

Returning From:
 
Account Number - {!relatedto.Account.Customer_Number__c}
Name - {!relatedto.Contact.Name}
Address - {!IF(relatedTo.Account.IsPersonAccount, relatedto.Account.PersonShippingStreet, relatedto.Account.ShippingStreet)}



Phone - {!relatedto.Contact.Phone}
Email - {!relatedto.Contact.Email}


</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Let me know if this helps.
Thanks,
Kaustav

All Answers

kaustav goswamikaustav goswami
It might be an issue with the brackets. Try this.

<messaging:emailTemplate subject="RMA Request" recipientType="User" relatedToType="Case" >
<messaging:plainTextEmailBody >

Returning From:
 
Account Number - {!relatedto.Account.Customer_Number__c}
Name - {!relatedto.Contact.Name}
Address - {!IF(relatedTo.Account.IsPersonAccount, relatedto.Account.PersonShippingStreet, relatedto.Account.ShippingStreet)}



Phone - {!relatedto.Contact.Phone}
Email - {!relatedto.Contact.Email}


</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Let me know if this helps.
Thanks,
Kaustav

This was selected as the best answer
BenPBenP
Thank you, that did the trick. 

For others to reference, here is how I displayed the address.  If it's a person account show the person mailing address, if not show the account shipping address.  I couldn't find a better way to either insert a new line, or create spaces so things lined up.

Address - {!IF(relatedTo.Account.IsPersonAccount, relatedto.Account.PersonMailingStreet , relatedto.Account.ShippingStreet)}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{!IF(relatedTo.Account.IsPersonAccount, relatedto.Account.PersonMailingCity & ', ' & relatedto.Account.PersonMailingState & ' '& relatedto.Account.PersonMailingPostalCode & ' '& relatedto.Account.PersonMailingCountry,
          relatedto.Account.ShippingCity & ', ' & relatedto.Account.ShippingState & ' '& relatedto.Account.ShippingPostalCode & ' '& relatedto.Account.ShippingCountry)}