I'm struggling with adding IF, THEN conidition to my HTML Classic Email template and hoping someone can help.

I am trying to say if Cohort Owner's name is 'X', then post the X link, if Cohort Owner's name is 'Y', then post the Y link and if Cohort Owner's name is 'Z' then paste the Z link.

This is the statement I am using in SF that is not outputting what I'd like

{!IF({!Cohorts__c.OwnerFirstName} = "Bob", "Boblink", " ")}
{!IF({!Cohorts__c.OwnerFirstName} = "Tim", "Timlink", " ")}
{!IF({!Cohorts__c.OwnerFirstName} = "Anna", "Annalink", " ")}

This is the output it gives me when I send an email.

 = "Bob", "Boblink", " ")} = "Tim", "Timlink", " ")} = "Anna", "Annalink", " ")}

I'd like the output to be dependent on Cohort Owner and have the output as, i.e Here is.. Annalink (if Cohort Owner is Anna)

Any suggestions?

1 Answer 1


Merge fields start with {! and end with }. You do not use {! or } within the merge field. In addition, you can use a CASE statement, which is easier to read.

  "Bob", "Boblink",
  "Tim", "Timlink",
  "Anna", "Annalink",

Or, if you prefer the IF statements, you can nest them together:

{!IF(Cohorts__c.OwnerFirstName = "Bob", "Boblink",
IF(Cohorts__c.OwnerFirstName = "Tim", "Timlink",
IF(Cohorts__c.OwnerFirstName = "Anna", "Annalink", " ")))}
  • Amazing, this worked like a charm. Definitely the CASE statement is easier to read and will be using that - thank you for introducing me to it :)
    – Samridhi
    Commented Nov 26, 2021 at 8:30
  • If I may ask a follow-up question - I'm trying to use it to display a particular hyperlink and thought this would work based on your suggestion. It just displays as blank as opposed to "this link" (hyperlinked to a specific link, i.e www.boblink.com if bob. Any thoughts? (Note the spacing between https:// and the link is just to post in the forum to show the code {!CASE(Cohorts__c.OwnerFirstName, "Bob", <a href="https:// boblink.com">this link </a>, "Tim", <a href="https:// timlink.com">this link </a>, "Anna", <a href="https:// annalink.com">this link </a>, "")}
    – Samridhi
    Commented Nov 26, 2021 at 9:16
  • @Samridhi You can use the HYPERLINK function to generate an appropriate link. {!HYPERLINK(CASE(Cohorts__c...), 'this link')} You can also do the HTML yourself, I'd recommend doing just the URL bit, as in <a href="{!CASE(...)}">this link</a>.
    – sfdcfox
    Commented Nov 26, 2021 at 15:34
  • Thaaank you - saved me so much hand banging time against a wall!
    – Samridhi
    Commented Nov 27, 2021 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .