function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cory CowgillCory Cowgill 

Attachment Trigger - Update Task Attachment Count

In Winter 11, we can now have Attachments on Tasks. I have a trigger (after update, after insert, after delete, after undelete) on Attachment which will update a custom field on Task with the Attachment Count. This works fine when adding or deleting Attachments in my Unit Tests as well as through UI on the Attachment screen if I update the attachment.

 

My issue is that if a user is on the Task "Edit" page, there is the button to "Attach File" on the Attachment section which gives you the popup to attach multiple files. When the user adds Attachments via this page the Trigger isn't firing for Attachments. I don't see the Attachment trigger even firing in the debug logs. Very odd. Anyone have any suggestions or similar experience?  Alternative solutions are accepted also.

 

This isn't a typical Master-Detail Relationship so you can't do Roll-Up Summary fields.


Thanks.

WizradWizrad

Hey Cory, its Phil, I hope your new gig is working out.

 

Is this a task that has already been inserted?

Cory CowgillCory Cowgill

What up Phil.

 

Its still early, but so far everythings good. Hope MM is treating you well.

 

As for this pesky Trigger, its a failing from the UI when doing an Insert in the Task Edit Screen -> Attach File.

 

But in my Unit Test for "insert attach" it works on the Trigger. Just seems to be through UI? But that doesn't make much sense since its a trigger on insert,update,delete......

 

Have you seen this before?

 

 

 

 

WizradWizrad

No, all I have to say is that I attempted to recreate your issue by creating a trigger on attachment with one line of code.  System.assertEquals('this', 'will fail');

 

I attempted to add an attachment through the UI and I got an error from the trigger.

 

Sorry I dont have any more to add, I really just wanted to say hello.

Cory CowgillCory Cowgill

Thanks anyway. I'll sleep on it, come at it fresh tomorrow morning. Its just weird because it works on the Unit Tests for the Triggers.

 

Keep in touch though dude. I haven't gotten my skype up and running again yet as the client site i'm currently at blocks it.

Cory CowgillCory Cowgill

Just updating this thread in case someone in the future comes across it.

 

This has been identified by Salesforce Premier Support - Tier 3 as a defect with Salesforce.

 

Per the email from the engineer at Salesforce:

 

"This mail is to inform you that the issue for which you have logged this case have been found as a bug and R & D team is working on this and will try to fix this soon.

I would recommend you to raise this issue after some time as we need some time to fix it up."

 

DuffAlthausDuffAlthaus

Hi Cory, 

I was wondering if you ever received an update on this?  When adding attachments through the Task -Edit, the triggers don't fire.  

Did you find any other type of work around?

Thanks

Duff

HareHare
here is answer for your quation
http://hareeshgoudsalesforce.blogspot.in/2016/12/custom-roll-up-summary-on-lookup-count.html