ExportFiles Core Add-On Module.
Table of Contents
- Overview
- Minimal ExportFiles Module Setup
- Full ExportFiles Module Setup
- Attachment Processing with core:ExportFiles
- Additional Notes
Overview ⇧
The core:ExportFiles module is designed to transfer Salesforce file-related entities and their binary content
in a controlled and predictable way. It helps when you need to migrate files together with parent records
and keep links between records and files consistent.
In the current engine, this module supports the following entities:
ContentVersionContentDocumentLinkAttachmentNote
It also supports all major transfer directions:
org -> orgorg -> csvfilecsvfile -> org
Minimal ExportFiles Module Setup ⇧
To transfer files linked to parent records, declare the module call in your export.json.
The minimal setup below upserts parent records (Accounts) and then runs core:ExportFiles.
In this minimal form, the module is declared without args.
{
"objects": [
{
"operation": "Upsert",
"externalId": "Name",
"query": "SELECT Name FROM Account",
"afterAddons": [
{
"module": "core:ExportFiles"
}
]
}
]
}
afterAddons in this example means the module is executed in the object-level OnAfter event.
This is important because parent records are already processed at that point, and file links can be created
against the target parent records.
Full ExportFiles Module Setup ⇧
Below is the full list of args properties relevant to the core:ExportFiles module. All properties are optional, so you can omit args completely if defaults are suitable for your scenario.
deleteOldData (Boolean) ⇧
Optional, Default: inherited from parent ScriptObject.deleteOldData (typically false).
If set to true, old target file records are deleted before uploading or linking new data.
Use this carefully in environments where target files must be replaced rather than incrementally updated.
operation (String) ⇧
Optional, Default: inherited from the parent object operation.
Specifies which operation to apply for file processing.
Typical values are Insert, Update, and Upsert.
If omitted, the module follows the operation used by the parent object.
If no operation can be resolved from context, the runtime fallback is Insert.
If Readonly is selected, the module will not process files.
externalId (String) ⇧
Optional, Default: Title.
Defines which ContentVersion field is used to compare source and target file records.
This is useful for deciding whether a file should be inserted as new, updated, or skipped.
baseBinaryFilePath (String) ⇧
Optional, Default: files.
Defines the base directory for binary file read/write operations in CSV media scenarios.
This option is useful when:
- binary files are stored outside the default working folder;
- you want a dedicated folder structure for file payloads;
- you need stable paths for automation.
Path handling supports both / and \.
sourceWhere (String) ⇧
Optional.
Adds an additional filter to source ContentVersion selection.
Use this to limit which source files are read, for example by title pattern or other criteria.
Sample Value: Title LIKE 'sample-%'
targetWhere (String) ⇧
Optional.
Adds an additional filter to target ContentVersion selection.
Use this when matching/updating/deleting only a subset of target files.
Sample Value: Title LIKE 'sample-%'
contentDocumentLinkOrderBy (String) ⇧
Optional.
Specifies the ORDER BY clause used when reading source ContentDocumentLink records.
This is useful when you need deterministic ordering (for example, most recent files first).
Sample Value: SystemModstamp DESC
maxChunkSize (Number) ⇧
Optional, Default: 15728640 bytes (15 MB), Max Allowed: 37 MB).
Limits the size of upload chunks sent in one operation.
Smaller chunk sizes may improve stability in constrained environments, while larger chunks can
improve throughput if network and org limits allow it.38797312 bytes (
maxFileSize (Number) ⇧
Optional, Default: 38797312 bytes (37 MB), Max Allowed: 37 MB).
Defines the maximum file size to process.
Files larger than this threshold are skipped by the module.38797312 bytes (
Attachment Processing with core:ExportFiles ⇧
core:ExportFiles processes Attachment records together with their binary content.
The module works through parent records selected by your object query.
In practice, this means:
- include parent objects (for example
Account) in your job; - run
core:ExportFilesinafterAddonsfor those parent objects; - use stable parent matching (usually
externalId) when target-side linking is required.
Scenario 1: Org-to-Org Attachment Transfer ⇧
Use this when both source and target are Salesforce orgs.
The module will move file-related records linked to selected parents, including Attachment.
{
"objects": [
{
"operation": "Upsert",
"externalId": "Name",
"query": "SELECT Id, Name FROM Account WHERE Name LIKE 'ACC_ATTACH_%'",
"afterAddons": [
{
"module": "core:ExportFiles"
}
]
}
]
}
Scenario 2: Org-to-CSV Export with Attachment Binaries ⇧
Use this when exporting from org to csvfile.
baseBinaryFilePath controls where binary payload files are stored.
{
"objects": [
{
"operation": "Readonly",
"externalId": "Name",
"query": "SELECT Id, Name FROM Account WHERE Name LIKE 'ACC_ATTACH_%'",
"afterAddons": [
{
"module": "core:ExportFiles",
"args": {
"baseBinaryFilePath": "./files/attachments"
}
}
]
}
]
}
Scenario 3: CSV-to-Org Import with Attachment Binaries ⇧
Use this when source is csvfile and target is an org.
The module reads file metadata from CSV plus binary payload from baseBinaryFilePath.
{
"objects": [
{
"operation": "Upsert",
"externalId": "Name",
"query": "SELECT Id, Name FROM Account WHERE Name LIKE 'ACC_ATTACH_%'",
"afterAddons": [
{
"module": "core:ExportFiles",
"args": {
"operation": "Upsert",
"baseBinaryFilePath": "./files/attachments"
}
}
]
}
]
}
Scenario 4: Replace Existing Target Attachments ⇧
Use deleteOldData=true when existing target file records should be removed before upload.
{
"objects": [
{
"operation": "Upsert",
"externalId": "Name",
"query": "SELECT Id, Name FROM Account WHERE Name LIKE 'ACC_ATTACH_%'",
"afterAddons": [
{
"module": "core:ExportFiles",
"args": {
"deleteOldData": true
}
}
]
}
]
}
Additional Notes ⇧
- This module processes file data that is linked to parent business records. In practical terms, parent records should be part of the migration flow so links can be resolved correctly.
- Supported transfer directions are:
org -> orgorg -> csvfilecsvfile -> org
- The module supports file-related entities handled by the current engine:
ContentVersionContentDocumentLinkAttachmentNote
Readonlyoperation is not supported for file transfer logic.- In
useSeparatedCSVFiles=truemode, CSV and binary path resolution follows object-set-aware folder logic. - Binary path resolution supports glob patterns, which is useful when file names are dynamic.
- This module is usually attached to events that run after parent records are prepared:
For additional details, see also Supported Add-On API Events.