function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
glowitzglowitz 

Using Formulas in Email Templates

Is there a way to use formulas in Email templates to handle conditional formatting?

For example, I'd like to use the formula UPPER( NAME HERE ) to cause the person's name to appear in all CAPS, even though it may appear as "Name Here" in the SFDC database. This is just one example.

Furthermore, there may be conditions upon which you do or do not want to show certain information in an email response. Using formulas would be helpful. I didn't see any documentation on this when search for "formulas in email templates" -- so I'm not sure if it's possible.

Thanks.
CRMsimpleCRMsimple
You can do that with HTML email templates but you will need to know some basic HTML in order to be efficient with it.
BenLBenL
I have found it is possible to use SFDC formulas in email templates.  I got the idea from online help where it says you can substitute text in case your merge field returns a null value by doing this;  {!NullValue(object.field, "text if null")}

I have used a few number type formulas for doing calculations in email templates and they've worked w/o issue.  Examples follow;

Fee: {!ROUND(Project_Work_Item__c.Word_Count__c * Project_Work_Item__c.Freelancer_Rate__c, 2)}

or

Fee: {!ROUND(Project_Work_Item__c.Word_Count__c * 2, 2)}


rpr2rpr2

Brilliant, BenL!

Rhonda



Message Edited by rpr2 on 08-03-2008 05:47 PM
SChopraSChopra

Hi Guys,

I am new to SF and have a questions on using auto response text e-mail:

We are currently using the Web to lead feature from Salesforce such that once someone fills out our form on our website, the fields in our leads are filled up and an automated e-mail goes to the client and a copy of the e-mail comes back to us. I am trying to include a mail merge option in this automated text e-mail such that a custom object text field under Leads called " questions for us" gets included in the e-mail. Final result should be that when the automated e-mail goes to the client and a copy to us it should include the text ( questions for us) the client had filled out online. I have tried using this formula {!Lead. Questions for us} but it does not seem to work. When I use {!Lead.Last Name} it works as Last Name is a standard field.. so my questions is what is the formula to include the custom field under leads so that I can use it in my automated text e-mail???

I would appreciate any help possible

 

Thanks!

BenLBenL
When you are creating the email template go to the 'available merge fields' section and in the 'select field type' box choose 'Lead Fields' and in the 'select field' box choose your custom field.  Then copy the value in the 'copy merge field value' box and paste it into your template.
wickwick
Have you used IF statements in the email templates?
I'm trying to use an IF expression in my email template, evaluating whether a checkbox is checked or not.
Here's my formula:
{!IF(Account.NewClient__c, "Welcome new client","Hello existing client")}
When I compose the email, it always displays "Hello existing client", no matter whether the "NewClient" checkbox is checked.
What am I missing? Is there some kind of special expression that I need to evaluate whether a checkbox field is checked or not?
    Is there something like ISCHECKED or ISCHECKVAL or some such expression that I need to use?
BenLBenL
Good timing. I did Friday and I can confirm they can be used. I was not evaluating any check box fields but if that is what your custom field is try wrapping it in () or try NOT(customfield) or try customfield=True or customfield="True".
fb123fb123
I am new to SalesForce as well -- just started customizing our system.

BenL, thanks a lot for the tip -- it's working great. I wasn't sure if formulas in e-mail templates were even possible, since I didn't see a Simple/Advanced Editor anywhere.

Has anyone found a way to display Related Lists in an e-mail template? We have a child custom object of Opportunities called Venues (similar to Products), and would like to send a template e-mail from Opportunities which includes a list of all Venues with certain Statuses.
BenLBenL
You can do that with VisualForce Email templates.  Here is a link to a sample.
fgwarbfgwarb

Hello!

 

How did you successfully use your custom checkbox fields in an email template?

 

I'm trying all of these with no results:

 

 

{!If(Lead.Agreed_to_Terms__c = "True", "Yes", "No")} {!If(Lead.Agreed_to_Terms__c = True, "Yes", "No")} {!If(Lead.Agreed_to_Terms__c = "1", "Yes", "No")} {!If(Lead.Agreed_to_Terms__c = 1, "Yes", "No")} {!If(Lead.Agreed_to_Terms__c == "1", "Yes", "No")}

 

 

Thanks! 

 

--edit for solution--

 this worked: 

{! if(Lead.Agreed_to_Terms_Conditions__c, "Yes", "No")}

 


--solution--

Message Edited by fgwarb on 02-19-2010 04:09 PM
Prasad_VeevaPrasad_Veeva

I am using the below format and getting null values. Here Urgent is check box field.

 

{IF(Urgent="true"), "Its Urgetn", "Its not Urgent")}

 

Any one can you please help me on this?

sparrowbradsparrowbrad

Hello,

 

Looking for a little help here.

 

I am trying to display a field value in an email template based on a picklist value

{!IF(ISPICKVAL(Opportunity.Partner_Sale__c,"Yes"),Opportunity.Amount_Gross__c,"")}

 

Everytime I run a test, I'm not getting a returned value when I should (obviously, I'm using an opportunity that has the picklist field with "Yes" as value)

 

To test if my formula was wrong, I entered (and it worked)

{!IF(ISPICKVAL(Opportunity.Partner_Sale__c,"Yes"),"Yes","No")}

 

Thanks!

Kyla WesterKyla Wester
I tried using the above formula from Fbward and got this back in the email:    ,"Yes","No")}

What was wrong? 
brailmbrailm
Hello, 

Looking some help. 
I'm tryimg to make my use case work with the provided example. It's not working. It's supposed to result in just the domain of the website.
{!RIGHT(Lead.Website, FIND( '.', Lead.Website)-1)}
Megha Lohia 10Megha Lohia 10
Hello everyone,

I am doing trailhead superbadges. I am new in salesforce unable to complete this challenge. I got this error.

There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, without email you cannot create a record: []

anyone help me out, please!
 
Tony LizarragaTony Lizarraga
Hello,

I need help with a formula in our email templates that are auto-sent out after a customer has filled out the web2case form. What we would like to accomplish is a simple statement that says "Based on your serial number, your unit is under/out of warranty". I suspect it would be an if statement  but need help since I'm new to salesforce.

I would imagine it would look like: "If serial number greater than 17350000 unit is under warranty, else, out of warranty".

Any help is much appreciated!