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
mnickelsmnickels 

Need code to delete chatter file uploads

Hello,

 

My goal is to keep only the most recent version of a chatter file.  When someone uploads a new version I want the old version to be deleted.  As far as I can tell this is not an option in salesforce.com.

 

My thoughts are creating a trigger on either a ContentDocument or ContentVersion that deletes the related ContentDocument or previous ContentVersion before the new version is uploaded, that way only one version will exist.  How can I accomplish this?

 

Thanks,

 

- Mike

 

 

davidjgriffdavidjgriff
It's my understanding that old versions of Content can't be "pruned". I'd love to be wrong on this, as this is one of my biggest gripes about Content.