File Uploads

Files uploads are supported by generating Content Documents in Salesforce.

Mapping

Map file fields to the field that contains the Id of the object that the Content Document should be linked to. In most cases this is simply the Id of the object the form is mapped to, e.g. Lead Id.

The Form field selection offers several individual properties. For automatic Content Document creation, select the overall option that is labelled with the form name only, whose value includes both filename and type.

Inbound Mapping options are as follows.

  • Default value only: a Content Document will only be generated for new records.

  • Always copy: a new Content Document will be added every time a file is submitted.

Content Document Links are created with Inferred permission.

Multiple files

Multiple files are also supported. In this case the Form field option does not show the file name and type, instead reading “(Multiple values [n])”. The field name selection is the same as for single files.

Limitations

The total size of all files in a single form submission is limited by the Maximum File Size client configuration setting. If the total size exceeds this setting then files will be omitted from the submission.

Try to avoid setting this limit excessively high, as it may create problems with Salesforce limits. For greater file storage capability a third party file service may be a better option. Hook into form submission responses with event handlers to relate external items to visitors.

Salesforce limits allow a maximum of 6 million characters per string. Due to the way files are encoded into the REST request, this limits the total size of each request to approximately 4.3MB. Requests which exceed the maximum will receive a response with 413 HTTP status code.

Complex requirements

Files may also be handled by directly mapping to the Content Version object. The :_fname, :_ftype and :_fdata properties may be mapped directly to the appropriate fields. The latter is automatically decoded to a Blob type which is suitable for the Version Data field.

To link the document to another object, the ContentDocument Id field must also be present so that the value can be chained to Content Document Link mapping. The send2crm service automatically re-loads the Content Version object to get the generated value when creating a new record.

External file sources

Large files and those shared with other systems may be handled as external documents using Salesforce Files Connect, e.g. with a Google Drive or SharePoint service.

Salesforce Files Connect documentation

  1. Perform the file upload to the external service using your website back end or as desired.

  2. Submit the file details with the send2crm form. The mapping should create a Content Version object similar to above, but with the Content Location set to “E” (for external) and the External Data Source Id set to your configured data source.