Friday, March 18, 2011

Bug in Email templates with similar Standard and Custom field names

I've been working on several workflow and email alerts lately.  I recently came across a curious defect with email templates.  Honestly, I don't know if it's strictly limited to the templates.  The defect involves an object which has standard and custom fields with the same 'name'.

If the object has a Standard field name and a custom field Name__c, an email template will pick up the custom field.

Steps to recreate:
1) Go to Setup->Create and Create a custom object 'obj' with a custom field of Name.
2) Go to Setup->Create and Create a tab to the custom object.
3) Go to the custom object tab and populate the object with Name='AAA', Name__c='BBB'.
4) Go to Setup->Communication Templates and create a test email template with:
  Subject: Name should be AAA {!obj__c.Name}
  Body: Name 1 should be AAA: {!obj__c.Name}
  Name 2 should be BBB: {!obj__c.Name__c}

5) Save the email template.
6) On the template, click 'Send test and verify merge results'
7) Populate the template with a valid contact and your new obj__c object.
8) You will see the defect.  The subject will say: Name should be AAA: BBB

No comments: