Saturday, August 20, 2011

Merge Field Functions in Email Templates

This may help to get people thinking about how much can be accomplished with text and HTML email templates before diving into Visualforce templates.

Did you know that you can substitute in text for blank values? By using the {!sObject.FieldName, substitute text including spaces} convention, blank values can be automatically replaced with default values.

Furthermore, it looks like at the email templates recognize at least two Visualforce-esque functions, demonstrated in the following examples:
  • {!NullValue(Lead.Name,"visitor")}, which is the same as the substitution described above
  • {!If(Lead.Name="Barack Obama","President","Citizen")}
  • {!If(IsPickVal(Lead.Status,"New"),"Super Important","Somewhat Important")}
Does anyone have any other information on what functions can be used in simple text or HTML email templates? Are all Visualforce functions available here, I wonder?