You need to sign in to do that
Don't have an account?
![jhart jhart](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Data consistency bug: Contact/Lead triggers skipped when Email is updated via Send Email page
If you send an email to a Contact or Lead from the Activity History "Send an Email" interface, and the Contact/Lead has a blank Email address, you are prompted to enter an Email address:
If you click "Save Address" or "Save Address and Send", the Contact/Lead will be updated with the given address.
However, no Contact or Lead triggers fire for this update (this is the bug).
Any app logic that depends on Contact/Lead triggers to detect Email address changes will therefore be left in an inconsistent state.
To verify this, I wrote a quick trigger for the Contact object:
trigger logEmailUpdate on Contact bulk (after delete, after insert, after update, after undelete) { string addrs = '\n'; for (integer i=0; i<Trigger.size; i++) { addrs += string.format('[{0}]: Email changing from "{1}" to "{2}"\n', new string[] { '' + i, Trigger.isInsert ? '(isInsert - no old record)' : Trigger.old[i].Email, Trigger.isDelete ? '(isDelete - no new record)' : Trigger.new[i].Email }); } AALog.log('DEBUG', 'Contact trigger fired ' + (Trigger.isBefore ? 'before' : '') + (Trigger.isAfter ? 'after' : '') + ' ' + (Trigger.isInsert ? 'insert' : '') + (Trigger.isUpdate ? 'update' : '') + (Trigger.isDelete ? 'delete' : '') + (Trigger.isUndelete ? 'undelete' : '') + ', email changes are ' + addrs ); }
The "AALog.log" method here writes a row to a simple logging object.
I then created a new Contact with a null address via the UI:
Contact trigger fired after insert, email changes are [0]: Email changing from "(isInsert - no old record)" to "null"
I then went through the "Send Email" interface as shown above & updated the Email address that way.
The trigger was not called, however the Contact was updated.
The very next thing I did was edit the Contact to delete the (silently updated) Email address. As expected, the trigger fired:
Contact trigger fired after update, email changes are [0]: Email changing from "test@ihance.com" to "null"
Note that the Email addr is already set, even though our trigger was never called for that update.
I then updated the Contact via the normal UI to set its Email field, to verify the trigger output is as expected:
Contact trigger fired after update, email changes are [0]: Email changing from "null" to "test@ihance.com"
This is what we should have seen when the Contact was updated from the "Send Email" dialog.
Finally I deleted the Contact altogether:
Contact trigger fired after delete, email changes are [0]: Email changing from "test@ihance.com" to "(isDelete - no new record)"
Note that all actions invoke the trigger except the Email update done via the Send Email interface.
Leads have the exact same bug.
Salesforce support - I created case 05987983 to track this issue.
OK, the guys at salesforce support are getting hung up on the AALog method & cannot compile, so to make it super simple:
To view the logging output, run this: