7

The Attachment Trigger is not firing for before insert and after insert events when attachments are added via the UI (Related to Tasks) in Winter 14 Sandbox, is this a bug? I've reviewed the known issues site and couldn't find anything similar. However, I did find others having issues with this same Trigger in the past (some reporting that the issue was resolved?). Can anyone shed some light on this?

Here is a quick example for before insert:

Apex Trigger:

trigger Attachment_Trigger on Attachment (before insert) {
    if(Trigger.isBefore)
    {
        if(Trigger.isInsert)
        {
            Attachment_BI_Add_Test.testChanges(Trigger.new);
        }
    }
}  

Apex Class:

public class Attachment_BI_Add_Test {

    public static void testChanges(Attachment[] newAttachments)
    {                
        for(Attachment a : newAttachments)
        { 
            a.name = 'test';
            a.Description = 'test';
        }
    } 
}

Other resources found with similar issues:

I've also checked the docs for operations that don't invoke triggers however, attachments are not mentioned:

  • 3
    According to the first blog post, it was a bug in the salesforce system according to the R&D - did you try opening a case with the Salesforce Support? – subodhbahl Sep 11 '13 at 16:45
  • I second opening a case. Support really wants to hear about this kind of thing, where something works in an unexpected way after a major release. – Carolyn Grabill Sep 19 '13 at 0:05
2

Here is my POC to show that winter '14 don't have such issue like On inserting an Attachment from UI doesn't fire the trigger.

I create the trigger and Apex class from the sample you provided and then inserted an Test Attachment file from UI on a record.

Trigger:

Attachment Trigger

Class:

Class same as sample but added debugs

Debug: Debug logs created for attachment trigger and System.debug lines were there. Debug log

Attachment has been renamed as "test" Note Attach

However on attachment upload notification detail page it doesn't show the name changed (even trigger got fired). It shows changed name (as sample trigger did) in related list.

There were no issues in trigger, may be this issue has been solved. Hope this help.

| improve this answer | |
  • Thank-you for looking into this exception. It only fails to fire the attachment trigger, when attachments are added when editing or creating new Tasks in Salesforce. I've created a support case with Salesforce. – rcraven Oct 4 '13 at 17:59
  • I've created a case with Salesforce basic support to promote this issue as a platform bug however, Salesforce support has closed our support case since we are not a Partner nor do we pay for Premier support. – rcraven Oct 15 '13 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.