Search code examples
salesforcevisualforcesalesforce-lightning

condtionally render the content in vf pag email template in salesforce


Depending upon account type( personal, commercial) need to render welcome message in VF page with if condition.

relatedToType="Account"

for commercial account

{!relatedTo.Name},

    
for personal account

Dear {!relatedTo.FirstName},



how to render the given requirement with if condition in vf page.

Solution

  • Try

    Dear {!IF(relatedTo.isPersonAccount, relatedTo.FirstName, relatedTo.Name)} for simple things. If you have bigger blocks of text - most VF tags have rendered attribute to turn them on and off.

    That's a weird requirement though. "Dear Four Seasons Total Landscaping..." ;)

    Who do you send it to when it's a company? Maybe use recipientType="Contact" and then recipient.FirstName?