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
Dan NorfleetDan Norfleet 

E-Discovery - Remove Chatter

I am creating a batch process to remove Chatter Posts after 180 Days.   Specifically the instructions are to remove the following:
  • Posts by group members & feed followers
  • Comments on posts
  • Attachments to posts of various media types such as pictures or PDF documents
To delete the FeedItem's I am selecting those > 180 days.  Then validate that the FeedItem originated either from a UserFeed or a CollaberationGroupFeed.  This seems to work fine for the posts.  

My question is how do I determine what attachments to remove?  I know you can have attachments on many objects, but the scope of mine are just the attachments for the chatter user / chatter group posts.

I can see when i create an attachment, it creates a FeedAttachment.  I can see that the ContentDocument.LastPublishedVersionId = FeedAttachment.RecordId.  How can I tell if the attachment is for a Chatter Group or Chatter User so i can issue the delete on the ContentDocument?

I appreciate any help you can provide.

Dan