Explore how Salesforce manages files using the ContentDocument, ContentVersion, and ContentDocumentLink objects. This repository includes detailed resources and examples from my YouTube demonstration.
YouTube: Master Salesforce File Management System with Apex Triggers, SOQL & Flows (With Practical Use Cases & Examples)
This repository is designed for developers and Salesforce admins who want to:
- Understand relationships between the
ContentDocument
,ContentVersion
, andContentDocumentLink
objects: their fields, usage, and purpose. - Learn Apex trigger-based scenarios for handling file uploads, updates, deletions, and record associations.
- Explore real-world use cases, including:
- SOQL queries for retrieving records across various scenarios.
- Querying all related files and their versions for any record using Flows.
- Previewing files and their versions in a data table.
- Generating secure, shareable links with optional expiration dates and passwords for external access.
-
On File Upload/Insert:
- All three objects—
ContentDocument
,ContentVersion
, andContentDocumentLink
—triggers are fired.
- All three objects—
-
On Uploading a New Version of a File:
- Only the
ContentVersion
trigger is fired.
- Only the
-
On Removing a File from a Record:
- The
ContentDocumentLink
trigger is fired on deletion, identifying the related record using theLinkedEntityId
.
- The
-
On Deleting a File from Salesforce:
- Only the
ContentDocument
trigger is fired.
- Only the
- ContentDocument, ContentVersion, and ContentDocumentLink Terminologies
- Trigger Behavior in Classic and Lightning Experience
- Clone the repository:
git clone https://github.com/IAm-RoyAnirban/Salesforce-Files-System.git
Feel free to fork this repository and contribute by submitting issues or pull requests. If you encounter any issues or need additional features, please raise a GitHub issue.
This project is licensed under the MIT License - see the LICENSE file for more details.