ExportFiles Core Add-On Module.


Table of Contents



Overview

The core:ExportFiles module is specifically designed to facilitate the efficient transfer of Salesforce File objects—including ContentVersion, ContentDocument, and ContentDocumentLink—along with their binary data and associated sObject records. It provides a seamless integration for handling complex data transfers within Salesforce environments, ensuring data integrity and consistency across systems.

Minimal ExportFiles Module Setup

To transfer Salesforce Files using the ExportFiles Core Add-On Module, simply declare the module call in your export.json. This minimal setup helps to Upsert Account records and then Insert Salesforce Files attached to these accounts. The files will be automatically linked to the correct records on the target side:

{
  "objects": [
    {
      "operation": "Upsert",
      "externalId": "Name",
      "query": "SELECT Name FROM Account",
      "afterAddons": [
        {
          "module": "core:ExportFiles",
          "args": {
            "operation": "Insert"
          }
        }
      ]
    }
  ]
}

"afterAddons" refers to the OnAfter Add-On event declaration (in the object's scope) where this module is triggered. This is executed AFTER the Account records have been fully processed. For more details, see the list of supported Add-On Api events.

Full ExportFiles Module Setup

Below is the full list of args properties relevant to the core:ExportFiles module. Since all properties are optional, you can omit the args parameter from the module declaration to use all default settings.

deleteOldData (Boolean)

Optional, Default: false. Set to true to delete old target files before uploading new ones.

operation (String)

Optional, Default: Same as the parent object. Specifies the operation to perform on the Files. This can differ from the operation applied to the parent object.
Sample Value: Update

externalId (String)

Optional, Default: Title. Identifies which field of the ContentVersion object is used to compare the source and target content versions to determine updates.

sourceWhere (String)

Optional. An extra WHERE clause to filter source ContentVersion records. Always includes 'AND IsLatest = true' to retrieve only the latest version.
Sample Value: Title ='sample-image'

targetWhere (String)

Optional. An extra WHERE clause to filter target ContentVersion records, typically used when needing to compare source and target versions.
Sample Value: Title LIKE 'sample-%'

contentDocumentLinkOrderBy (String)

Optional. Specifies the ORDER BY clause for the query used to select source ContentDocumentLink records. This clause is useful for defining the order of files, ensuring that the most recent files in the source organization are also the most recent in the target organization.

maxChunkSize (Number)

Optional, Default: 15. Limits the size of data chunks (in Bytes) transferred simultaneously to improve performance. Should not exceed 37MB.

maxFileSize (Number)

Optional, Default 37. Controls the maximum size of files (in Bytes) to be transferred. Files larger than this are ignored. Should not exceed 37MB.

Additional Notes

  • The Add-On only operates with files linked to parent object records that have already been uploaded to the Target org.

  • Export of files to or from CSV files is not supported.

    • Upsert: Inserts new files and updates those that have changed in the Source org.
    • Update: Selectively updates changed files without transferring new files.
    • Insert: Inserts all files regardless of their presence in the Target.
    • Delete: Only deletes target files. You can limit the number of files deleted by using the targetWhere property.
  • The Readonly operation is not supported for files.

  • The externalId property is part of the ContentVersion object with the default being Title.

  • The Add-On splits large volumes of input files into smaller chunks to minimize memory usage and downloads binary content in parallel to enhance download speed while maintaining control over parallel downloads.

  • The maxChunkSize parameter refers to the organization of multiple ContentVersions into a bundle sent to the Salesforce server in a single transaction. It is recommended to avoid uploading large files to prevent issues related to system limitations. For more information, see Salesforce documentation on file size limits.

  • This module, which transfers files attached to specific records, requires that these records be pre-imported into the target organization. Therefore, the suitable events to utilize with this module are only:

    For additional details, see also Supported Add-On API Events.

Last updated on 14th Aug 2024