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
    {!IF(Enquiry__c.Destination__c == "Barcelona", "i am barcelona", "i am not barcelona")} – nanbatman Aug 27 '18 at 2:05
3

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.

  • formula works best, custom email template has some disadvantages to keep editable text before sending. – Santanu Boral Aug 9 '17 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. – Matthew Aug 9 '17 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")}
  • 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. – Derek F Aug 24 '18 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.