Trigger on Attachment does not fire when attachment is created via Email
Last updated 2017-09-25 ·Reference W-2494367 ·Reported By 22 users
No Fix
Summary
Trigger on Attachment object does not fire *when* the attachment is created :
(a) via Case Feed Email Publisher.
(b) when user sends email via Related List, and adds an attachment file,
* Note: Trigger fires when the attachment object is created via email-to-case, or by user via UI.
Repro
Create the following in an Org (For Eg. A Developer Edition) :
- Enable case feed
- Enable email draft
- Enable email-to-case
Create a new apex trigger called "AttachmentTrigger" :
trigger AttachmentTrigger on Attachment (before insert, after insert, before update, after update, before delete, after delete) {
System.debug('invoking attachment trigger');
if (Trigger.isBefore) {
if (Trigger.isInsert) {
System.debug('XXXXXXXXXXXXXXXXXXXX attachment before-insert');
} else if (Trigger.isUpdate) {
System.debug('XXXXXXXXXXXXXXXXXXXX attachment before-update');
} else {
System.debug('XXXXXXXXXXXXXXXXXXXX attachment before-delete');
}
} else {
if (Trigger.isInsert) {
System.debug('XXXXXXXXXXXXXXXXXXXX attachment after-insert');
} else if (Trigger.isUpdate) {
System.debug('XXXXXXXXXXXXXXXXXXXX attachment after-update');
} else {
System.debug('XXXXXXXXXXXXXXXXXXXX attachment after-delete');
}
}
}
These are the scenarios and their corresponding results :
Attachment Trigger does *not* execute in these scenarios :
- Send email from Case Related List and add attachment
- Send email from Case Feed - Email Publisher and add attachment
- Write/Save email from Case Feed - Email Publisher and add attachment (draft email)
- Delete attachment in draft email in Case Feed Email Publisher
Attachment Trigger does execute in these scenarios :
- Email-to-Case with file
- Attach file on Case
- Edit attachment in Email detail page when the File Name is changed
- Edit attachment in Case when the File Name is changed
- Delete attachment in Email detail page
- Delete attachment in Case
- Attachment insert/edit/delete for Account and Contact detail pages work successfully.
Workaround
N/A
Reported By (22)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.