+ Start a Discussion
MC AdminMC Admin 

Issue with conditional if statement in plain text email template

We want to have our plain text email templates address a couple by their first names if both names are available, otherwise address just the client's first name.
Examples:
- If the father's first name field has the name "Paul" and the Client's first name is "Lainie", the email should start with "Dear Paul and Lainie,"
- If the father's first name field is blank, the email should start with "Dear Lainie,"

We have searched the forums and still can't seem to make a formula work. We have tried the following:

Dear {!if({!Babies__c.Fathers_First_Name__c}="",{!Babies__c.Client_First_Name__c},{!Babies__c.Fathers_First_Name__c} and {!Babies__c.Client_First_Name__c}),

The output we get with this formula is:
Dear ="",Lainie,Paul and Lainie),

Any help would be much appreciated.
Best Answer chosen by MC Admin
Malni Chandrasekaran 2Malni Chandrasekaran 2
MC Admin,
Please try,

Dear {! IF(Babies__c.Fathers_First_Name__c == "", Babies__c.Client_First_Name__c, Babies__c.Fathers_First_Name__c + " and " + Babies__c.Client_First_Name__c)}


Please mark is as solved if it helps you solving issue and get back to me if it does not work for you too.

All Answers

Malni Chandrasekaran 2Malni Chandrasekaran 2
MC Admin,
Please try,

Dear {! IF(Babies__c.Fathers_First_Name__c == "", Babies__c.Client_First_Name__c, Babies__c.Fathers_First_Name__c + " and " + Babies__c.Client_First_Name__c)}


Please mark is as solved if it helps you solving issue and get back to me if it does not work for you too.
This was selected as the best answer
Shruti SShruti S
I would recommend checking the blank fields with ISBLANK function. Here is the formula employing the ISBLANK - 
Dear {!IF(ISBLANK(Babies__c.Fathers_First_Name__c),Babies__c.Client_First_Name__c,Babies__c.Fathers_First_Name__c + " and " + Babies__c.Client_First_Name__c)},
Note: After copying from here, please use the "Paste as plain text" (Ctrl+Shift+V) while you are on the Email Template in Salesforce.
MC AdminMC Admin
@Malni Chandrasekaran 2

Thank you, that worked perfectly!
MC AdminMC Admin
@Shruti S

Thank you for your suggestion.  We already implemented the other formula.