1

I want to add conditional logic to my text email template.

Here is what I tried:

Destination__c = {!Enquiry__c.Destination__c} {!IF("{!Enquiry__c.Destination__c}" = "Barcelona", "i am barcelona", "i am not barcelona")} 

When I sent a test message, I got the following:

Destination__c = Barcelona i am not barcelona 

I'm aware of formula fields, but I'd rather have the logic in the template. Although, if I need to make a formula field, I'm willing to do so.

1
  • 1
    {!IF(Enquiry__c.Destination__c == "Barcelona", "i am barcelona", "i am not barcelona")} Commented Aug 27, 2018 at 2:05

4 Answers 4

4

Try the following:

{!CASE(Enquiry__c.Destination__c, "Barcelona", "i am barcelona", "i am not barcelona")} 

If that doesn't work with a simple Text Email Template, try re-creating as a Custom HTML Email Template, it should work.

2
  • formula works best, custom email template has some disadvantages to keep editable text before sending. Commented Aug 9, 2017 at 5:44
  • It worked! Thanks, iDog. The reason why I don't want to use formula fields is because I want to conditionally show a sentence depending on the value of Destination__c. Commented Aug 9, 2017 at 6:01
1

Conditional logic only works correctly if you use Visualforce Email Template.

For, Text or HTML based email templates, you need to create a formula field which will return results based on your conditions.

0

Try out this once -

{!IF({!Enquiry__c.Destination__c} == "Barcelona", "i am barcelona", "i am not barcelona")} 
0

Replace {!Enquiry__c.Destination__c} with Enquiry__c.Destination__c

{!IF(Enquiry__c.Destination__c == "Barcelona", "i am barcelona", "i am not barcelona")} 
1
  • 2
    Welcome to SFSE! This looks more like it should be a comment on (or an edit to) another answer, rather than an answer by itself. Usually, a good answer will go into detail about what the problem is (in this case, an extra {!} in the formula), how to fix it, and why the fix works. Normally, new users aren't able to comment on other people's questions/answers (50 reputation required), but since you linked your account from other SE sites, you have 100 reputation. I'm recommending a deletion for this one. Commented Aug 24, 2018 at 12:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.