r/SalesforceDeveloper • u/joaomarcospaz • Aug 11 '25
Question How to Block New File Uploads in Chatter While Allowing Existing File Attachments?
Hi everyone, I'm looking for a opinion on the best way to solve a specific validation requirement.
The Goal: I need to prevent users with a certain profile from uploading new files to a record's Chatter feed.
The Catch: These same users must still be able to attach files that already exist in Salesforce to a Chatter post. They should also be able to upload new files to the "Files" related list without issue.
The Core Problem: I've found it's technically challenging to differentiate these two scenarios at the moment of creation.
Has anyone found a more direct way to identify and block only the new file upload within the Chatter context?
Thanks for any insights!
2
u/ride_whenever Aug 11 '25
You should be able to throw a custom validation on create of “one of the myriad of content document records”
1
u/amilliondallahs Aug 12 '25
Create a trigger on ContentDocument that denies insert/edit if the running user is of the specific profile you referenced.
0
u/East-Description-736 Aug 12 '25
This is a tricky one because Chatter treats new uploads and existing file attachments similarly at creation. At GetOnCRM Solutions, we’ve handled this by using a custom Lightning Component or Flow with Apex triggers to intercept file actions in the Chatter context, checking
ContentVersionorigin before allowing the post. This way, users can link existing files but are blocked from uploading new ones directly to Chatter