Salesforce Trigger on File Delete

When a file is deleted in Salesforce, trigger on ContentDocument object/entity fires. But, the trigger on ContentDocumenLink object/entity will not fire.

Sample Trigger:

trigger ContentDocumentTrigger on ContentDocument ( after delete ) {
    
    for ( ContentDocument objCD : trigger.old ) {
        
        System.debug(
            'Deleted Document Id is ' + 
            objCD.Id
        );
    }

}

Salesforce Help Article:

https://help.salesforce.com/s/articleView?id=000381623&type=1

Leave a Reply