2

I would like to show a picklist value based on a condition in email template, tried the below but it is not displaying result as expected.

<p>{!If(ABC__c.Country__c="USA", ABC__C.Language__c , "")}</p>

The below two scenarios displays the result as expected

  • <p>{!ABC__c.Country__c}</p>
    • Displays : USA
  • <p>{!ABC__C.Language__c}</p>
    • Displays : English

Country__c is a formula field and Language__c is Picklist field. I would like to display the language in the email template only if Country__C is USA.

1
  • Language__c is a picklist field . Country__c is formula field
    – KSR
    Commented Sep 14, 2017 at 13:32

2 Answers 2

2

I ran into this problem as well. Since Salesforce does not officially support Formulas in Email Templates there seem to be a lot of things that just don't work.

Such as Displaying Picklist fields. We are also unable to convert them to text in the Template.

However, you have the option to create a Formula field that converts the Picklist to text and you are able to use that field in the Template. This is usually not the best solution since you don't want to create unnecessary fields.

The other option would be to make a VisualForce Email Template instead.

If you have a short Picklist then you can stack some IF statements.

Example with 1 IF statement:

{!IF(AND(ISPICKVAL(ABC__c.Language__c, "English"), ABC__c.Country__c="USA"), "English", null)}

Example with 2 IF Statements:

{!IF(AND(ISPICKVAL(ABC__c.Language__c, "English"), ABC__c.Country__c="USA"), "English", IF(AND(ISPICKVAL(ABC__c.Language__c, "Spanish"), ABC__c.Country__c="USA"), "Spanish", null))}

Example with 2 IF Statements in a cleaner way:

{!IF(AND(ISPICKVAL(ABC__c.Language__c, "English"), ABC__c.Country__c="USA"), "English", null)}
{!IF(AND(ISPICKVAL(ABC__c.Language__c, "Spanish"), ABC__c.Country__c="USA"), "Spanish", null)}

This starts to look messy though and I am not sure about the limits. These are just the possible workarounds to the issue that I found.

Hope this helps someone even though the question is so old!

0

{!If(ABC__c.Country__c**=**="USA", ABC__C.Language__c , "")} Are you missing an equal sign?

1
  • Hi daniel, the if condition is working fine, but the value ABC_C.Language__C is not showing up.
    – KSR
    Commented Sep 14, 2017 at 13:40

You must log in to answer this question.

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