+ Start a Discussion
MarimuthuMarimuthu 

Salesforce Cases - Related Emails - Need a COUNT of Attachments

On the Related Emails List View of a Case, users are asking for a COUNT... Number of Attachments on each email in the list. The Count should be viewable in the Related Email list
NagendraNagendra (Salesforce Developers) 
Hi Marimuthu,

Emails are stored in the Email Message object and relevant attachment stored in the Attachment object with Link with ParentID as EMailMessage ID,
so as per your requirement,
1) to Create a custom field in EMail Message object called no of attachment (number field)
2) Create an Apex Trigger in Attachment object and count the value against with EmailMessage Parent ID
For Example, to count the child record to the parent level.
here child is account
the parent is an email message.

Some Reference:
  • https://success.salesforce.com/answers?id=90630000000gmlzAAA
  • http://www.sfdcchampions.com/2015/04/trigger-to-count-number-of-attachments.html
Thanks,
Nagendra