In Salesforce, files attached to records are stored as ContentDocument objects. The relationship between a file and a record is represented by a ContentDocumentLink object — each ContentDocumentLink links one ContentDocument to one record.
When a file is deleted, the Apex trigger behavior differs between Salesforce Classic and Lightning Experience. This difference is important for developers who write custom Apex triggers on the ContentDocument or ContentDocumentLink objects, as the trigger that fires depends on which experience the user is working in.
When a user deletes a file from the Files related list in Salesforce Classic, Salesforce deletes only the ContentDocumentLink record — it does not delete the ContentDocument itself. As a result:
When a user deletes a file from the Files related list in Lightning Experience, Salesforce deletes both the ContentDocument and its associated ContentDocumentLink records. As a result:
To verify trigger behavior in your org:
System.debug() statement in each trigger.000381623

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.