Friday, July 15, 2011

Lead and Contact Merge Fields in Email Templates

Interesting note about Lead and Contact merge fields in Salesforce email templates: Some of the fields will populate regardless of whether the record is of the correct type.

For example, in my template, the first line read:
Dear {!Contact.FirstName}{!Lead.FirstName},

I figured that only one of the two fields would actually produce the target's first name. However, when I actually tested the merge fields in Salesforce with a Contact record and with a Lead record, in both instances the result read:
Dear JohnJohn,

Interestingly, this duplicate merge did not occur in the signature, where I had the following:
Sincerely,
{!Contact.OwnerFullName}{!Lead.OwnerFullName}

In the signature, only the relevant OwnerFullName field was populated, depending on whether a Contact or a Lead was selected.

I wonder whether this phenomenon is intentional or indicative of a bug...