Salesforce Engineering · Technical guide
Salesforce Files at scale: the ten decisions that decide whether document management holds
Attachments versus Files, library taxonomy, Files Connect, and the sharing decisions that are expensive to reverse once an org is live.
- Written by
- Marcin JeziorekSalesforce Technical Architect
- Published
- · updated
- Reading time
- 5 min read
Document chaos in Salesforce is one of the most underestimated productivity killers in enterprise orgs. Sales reps waste time hunting for the right contract version, service agents re-upload attachments that already exist, and compliance teams dread audit season. After years of working on enterprise Salesforce orgs across Poland and the EU, we've distilled the ten practices that consistently make the biggest difference.
1. Migrate from Attachments to Salesforce Files - if you haven't yet
The legacy Attachments object lacks the versioning and sharing model available through Salesforce Files (ContentDocument / ContentVersion). Run a SOQL query against Attachment to measure your exposure, then plan and test a migration with tooling appropriate to the org. Estimate effort only after reviewing file volume, links, permissions, and downstream integrations.
2. Design a library taxonomy before users touch anything
Content Libraries in Salesforce Files let you group documents by purpose - "Customer Contracts", "Product Specs", "Finance Templates". The mistake most orgs make is creating libraries reactively, after documents already exist. Work with key stakeholders to map the document taxonomy: business unit → document type → lifecycle stage. Library access can then reinforce that taxonomy.
3. Enforce file naming conventions with validation rules
A shared drive with files called "final_v3_REALLY_FINAL.docx" is the natural state of entropy. In Salesforce you can enforce naming patterns at the ContentVersion level using Apex triggers or Flow-triggered validation. Native validation rules are not triggered on every upload path (Salesforce documents that validation rules on the Content Version object are not triggered for Chatter uploads, and are triggered from the Files tab in Lightning but not in Classic), so test every route a file can take in. A simple pattern like {RecordType}_{AccountName}_{YYYY-MM-DD} makes search and audit dramatically easier. Document the convention in your org's Confluence and add a tooltip to the upload modal using a custom LWC if the standard UI doesn't surface it.
4. Use version control - never overwrite
ContentVersion supports versioning natively: uploading a new file against the same ContentDocumentId creates a new version while preserving history. Train users to always "upload new version" rather than deleting and re-uploading. Once a document reaches a "Signed" or "Approved" status, limit who holds Collaborator access and enforce the rule with a process of your own, for example Apex on ContentVersion insert. Do not assume Salesforce Files has a native lock, and verify the behavior in your org.
5. Automate filing with Flow and record-triggered automation
Manual filing is the enemy of consistency. Use automation to link uploaded files to the correct record or library and set metadata fields (document type, expiry date, owner) based on context. For example: when a ContentVersion is uploaded to an Opportunity in "Contract Sent" stage, classify it as a contract and apply the agreed filing rules. Validate the exact automation approach against Salesforce Files constraints before estimating it.
6. Connect external storage with Files Connect
If your organization runs SharePoint Online or Google Drive as its canonical document store, don't fight it - connect it. Salesforce Files Connect lets users search and link external files from Salesforce. In Reference mode the files stay in the source system and no previews are available (files from SharePoint Online and OneDrive for Business cannot be previewed in the file preview player); in Copy mode Salesforce stores a copy, which does not follow later revisions made in the source. For cloud sources such as SharePoint Online, OneDrive for Business, Google Drive and Box, setup is declarative in Setup: enable Files Connect, create an authentication provider for the source (OpenID Connect, with an OAuth app registered at the provider), define an external data source that uses it (Per User or Named Principal identity), and grant users the Files Connect Cloud permission and access to the data source. Setup differs by connector, so follow the documentation for yours.
7. Apply rich metadata tags for discovery
For enterprise discovery, define metadata such as document type, originating system, expiry date, and sensitivity classification using supported fields or a related data model. The metadata can power operational views such as documents approaching expiry or unsigned contracts awaiting attention. Confirm object-level customization support in the target org before committing to a design.
8. Control file access through libraries and record access, not ad hoc sharing
Salesforce Files are shared through ContentDocumentLink records, which link a file to a user, group, record or library with a ShareType of Viewer (V), Collaborator (C) or Inferred (I). For a file attached to a record, access can be inferred from that record when the file follows the record's access; files in a library follow the library's permissions. Control access through library membership and permissions, the setting that makes record files follow record access, the Private on Records and Prevent others from sharing options on sensitive files, and by keeping Modify All Data and View All Data to a minimum, because they grant built-in access to files. Audit ContentDocumentLink data and file ownership quarterly. Users cannot be deleted, only deactivated, and files owned by a deactivated user are not deleted: they stay owned by that user until an administrator reassigns them, so include file ownership transfer and a review of shares in your offboarding process.
9. Monitor storage and plan for growth
Salesforce storage is finite. Use the Storage Usage page in Setup as a baseline, then monitor growth by document type, owner, and creation date. Set alert thresholds from the org's capacity plan, and define archive eligibility from legal, operational, and records-management requirements rather than a generic age rule.
10. Integrate AI-based classification with Agentforce
AI-assisted classification can be useful when rules alone cannot consistently identify document type or metadata. Treat the model output as a governed suggestion, define confidence and review behavior, and test it on the organization's own document set before automating downstream actions.