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 feature works reasonably well, especially with the new Lightning ‘Files’ implementation, which has replaced the legacy classic ‘Attachments’ (migration is automatically handled when 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.
  • 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 workflows.
  • 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 enhancing file attachments can be categorized as follows:

OptionVendors/PackagesProsCons
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.

First, it’s essential to note that object storage and file storage 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 only be queried using a specific id or a set of ids with the IN clause. Examining larger sets of attachments requires downloading data via Data Loader, a backup or a database replication tool.

Pro TipObject 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.

ImportantMost 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’s clear from the scope above that some development in APEX and Lightning is required. Additionally, migrating documents from sources outside Salesforce typically involves orchestrating the Salesforce REST API, storage API (some vendors offer an SDK that simplifies this process), data transfers, and migration logic written outside of Salesforce, such as in Python, Java, C#, or other programming languages.

Conclusions

Choosing an alternative external file storage solution for Salesforce can be challenging due to the wide range of options and varying business requirements. Implementation and file migration may also require significant effort and careful project planning.

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