We have files with special categories, if a new file is uploaded the category is mandatory for each file. Category A - can deleted Category B - cant deleted

I though I can make a validation rule like "Text(category__c) == "B". But if I upload a new file with category B I get my error which I have added for the validation rule.

Second idea was to add a flow to validate the deletion, but I can't choose the file object for run the flow if record is deleted.

  • as suggested by @davidCheng below both suggested options by you are not feasible. Easiest to write a trigger event. However, it may not a bad idea to evaluate if such a need arises for the other type of file; in the future, the solution you would build for this should be configurable enough to add more filters/ rules for such use cases; only if adding value, not just one field. #foodForThought
    – GirishP
    Commented Jun 14, 2021 at 15:06

1 Answer 1


You will have to write an Apex trigger to prevent deletion of ContentDocument (file) records. Validation rules cannot prevent record deletion, and you currently cannot use Flow on the ContentDocument object.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .