• Kavitha J Subramanya
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi, I'm facing a problem when deleting documents uploaded via Chatter.

So I have a numeric field called "TotalNumberOfDocuments__c" on Opportunity level that will increase/decrease everytime files are uploaded or deleted.

These are the cases:
- Attachments can be uploaded via Notes & Attachments related list (so far so good)
- Attachments can be deleted via Notes & Attachments related list (so far so good)
- Files can be posted on the opportunity feed (so far so good)
- Files can be deleted when feed post is deleted (so far so good)
- Files can be deleted via Notes & Attachments (outch)

The problem is that when a file is uploaded via Chatter and later is deleted on the Notes & Attachments related list (in this case a ContentDocument is deleted, but the FeedItem is kept). I can't find a way to get the opportunity which the file is related to.
Is there a way to get the FeedItem Id from the ContentDocument object that was delete? Via trigger after delete on the SObject ContentDocument?

Thanks