Featured image of post Salesforce: A Command to Delete All Chatter Posts and Attachments

Salesforce: A Command to Delete All Chatter Posts and Attachments

Introduces a command useful when an organization's storage capacity is tight in Salesforce, to batch delete all Chatter posts, attachments, and recycle bin data. It's a method to quickly clean up using the Execute Anonymous window from the Developer Console.

Salesforce Chatter Bulk Delete Command

This is a command to delete all posts and attachments in Salesforce Chatter. Open the Developer Console, select “Open Execute anonymous Window” from the Debug menu, paste the following code, and execute it. I personally use this when the organization’s storage capacity is running low.

1
2
3
4
5
6
delete [select id from FeedItem];
delete [select id from FeedAttachment];
delete [select id from ContentDocument];

// Empty the recycle bin
database.emptyRecycleBin([select id from ContentDocument where IsDeleted = true ALL ROWS]);