Overcoming Salesforce attachment limitations with external file storage

Salesforce enables adding file attachments to accounts, opportunities and other objects.

Attachments are visible in the Notes & Attachments section in record details. They can be added to both standard and user-defined objects — the latter is important for custom objects provided by packages extending the standard CRM functionality (for example, most Nextian custom objects such as work orders support attachments).

The standard attachments work reasonably well, especially when using the new Lightning ‘Files’ implementation that replaced the legacy, classic ‘Attachments’ (migration is performed automatically by switching to the Lightning experience).

However, for businesses that rely heavily on documents, the standard Salesforce functionality may be insufficient due to:

  • Storage limitations — Salesforce storage is limited by the plan and number of users (typically 2GB per user and 10GB per org) while most third-party storage providers offer unlimited space
  • File size limitations — 2GB for Lightning and 25 MB for Classic (see this link for details)
  • Storage cost — third party systems are usually more cost effective
  • Ability to search content of attached documents in popular formats (.doc, .pdf, .xls, etc.)
  • Sharing documents with other IT systems
  • Execute complex document approval flows
  • Organize documents in sub-folders — Salesforce attachments are added to an object as a list, while third party systems usually offer ability to create a folder structure underneath a record
  • Limited user experience — the standard Salesforce attachment interface is relatively simple and not geared towards efficient use
  • Content upload/download speeds — specialized document systems offer higher speeds (up to 3 times, based on our measurements)
  • Lack of collaboration features — e.g., document checkout, lock, see who is editing, open and save via a desktop application, etc.

Available options

Depending on business objectives and needs, options for improving file attachments can be categorized as follows:

Option Vendors/Packages Pros Cons
Using built-in attachments and
purchasing additional storage
  No changes required (just pay). Does not address any limitations outlined above.
Using external file storage
  • BOX.COM
  • Dropbox
  • Amazon S3
  • Google Drive
  • Salesforce Files Connect (e.g., with Microsoft SharePoint)

Larger (in some cases unlimited) storage, good search capabilities.

Good integration can enable users to spend 100% of their work time in Salesforce without having to switch between the systems.

Coding in Lightning and APEX may be required.

Document migration from Salesforce to the new storage system might be a challenge.

Integration with a fully-blown Document Management System (DMS)
  • DocuSign CLM (f.k.a. SpringCM)
  • S-drive

Has all the pros of using external file storage enhanced with DMS features (document generation, workflows, approvals, etc.).

Best choice for businesses building their processes around document flows.

Usually a large project, associated with a DMS rollout.

Built-in attachments

Understanding built-in Salesforce attachments is a good first step for choosing a replacement and understanding potential security and migration issues.

Firstly, object and file storages are separate (Setup → Company Information):

Available Salesforce storage information
Available Salesforce storage information

Understanding Salesforce attachment structure

Attachments are linked to documents via the following tables:

ContentDocumentLink → ContentDocument → ContentVersion

ContentDocumentLink links parent object ids such as opportunity, account, etc. with the documents. The following SOQL query can be used to retrieve links for any Salesforce object:

SELECT
  ContentDocumentId, /* id of document linked to parent*/
  ShareType          /* sharing mode, e.g. 'V' view only, 'I' infer from record permissions */
FROM
  ContentDocumentLink 
WHERE
  LinkedEntityId = '0015g000003YnHlAAK'  /* parent object id, = or IN operators must be present */
 

The LinkedEntityId in the query represents parent object id.

ContentDocumentLink can be only queried with a specific id or a set of ids via IN clause. Examining larger sets of attachments requires downloading data via Data Loader, backup tool or database replication.

Pro Tip Object key (the first three characters of LinkedEntityId) can be used to obtain statistics on attachments per object type.

The value of ContentDocumentId from the query above can be used to query document properties:

SELECT
  Title, 
  FileType, 
  FileExtension, 
  Description 
FROM
  ContentDocument 
WHERE
  Id = '0695g000000gG0UAAU'

This does not however return the document content. Since content is versioned and has to be pulled from the ContentVersion table:

SELECT
  Id, 
  IsLatest 
FROM
  ContentVersion 
WHERE
  ContentDocumentId = '0695g000000gG0UAAU'
 

Attachment security model

The ShareType field on ContentDocumentLink (in the query above) determines how a particular attachment is shared:

  • ‘V’ – creator full access, other users view only
  • ‘I’ – infer from object (i.e., follow permissions on the particular record)
  • ‘C’ – creator full access, other users must be granted access

The Salesforce org default is ‘V’ however it can be changed to ‘I’ via Setup → Feature Settings → Salesforce Files → General Settings and checking Set file access to Set By Record for files attached to records:

Salesforce files settings

Unfortunately, this option works for new attachments only and existing records must be changed with the Data Loader or other tool.

Important Most external storage add-ons (e.g., BOX.COM) support some sort of equivalent of the ‘I’ sharing type.

Using external file storage — considerations

Integration effort will depend on the selected storage provider.

For example, making Google Drive or Microsoft SharePoint files available for individual users via Files Connect is a considerably smaller effort than a complex BOX.COM integration.

Regardless of external storage chosen, a typical integration involves:

  • Modifying Lighting record pages to embed new external access components
  • Migration of existing documents from Salesforce native to external storage attachments
  • Optional migration of documents from other sources
  • Automated creation of documents folders and sub-folders
  • Creation and association of folders for existing records that do not have attachments yet
  • Administrative lighting actions — there are chances that things will go wrong so actions like ‘Create Folder Structure’ need to be made available to system administrators
  • Security and audit configuration
Salesforce account with attachments in Box.com
Salesforce account with attachments in Box.com

It is easy to notice from the scope above that some development in APEX and Lightning is involved. Also, document migration from other sources than Salesforce usually requires orchestration of Salesforce REST API, storage API (some vendors offer a SDK making things much easier), data transfers and migration logic written outside Salesforce, e.g., in Python, Java C# or other programming language.

Conclusions

The choice of alternative external file storage for Salesforce can be difficult due to a large number of options. Implementation and file migration may be a considerable effort and require good project planning.

Nextian is a vendor of Quote-to-Cash (QTC) software for cloud and communications helping providers accelerate growth and increase customer lifetime value.

Contact us today to find out how we can help you!

Thank you for contacting Nextian. Your request was successfully submitted, we will get back to you within two working days.

BY INDUSTRY

Cloud Infrastructure Providers

Cloud Software Companies

Managed Service Providers

Communications Service Providers

BY ROLE

CEO / Owner

CRO / VP Sales

CFO / VP Finance

COO / VP Operations

CPO / VP Product

CIO / VP IT

Product Management

Plan, launch and manage your product offerings throughout their entire lifecycle.

CPQ & Sales

Quickly create accurate quotes for complex products, subscriptions and add-ons

Order Management

Ensure faster, consistent order delivery with tasks, workflows and automation

Service Management, Support & Monitoring

Retain and upsell customers with comprehensive account intelligence, support, monitoring, analytics

Customer Portal

Empower your customers with 24/7 self-service, support and on-line ordering

NEXTIAN PLATFORM

Platform Overview

Billing Integration

Network Monitoring Integration

Reporting & Analytics