Loading

Salesforce System Administrator Cannot Export All Content Files (ContentDocument) via Data Loader

Дата публикации: May 30, 2026
Описание


A common option used to export all Content is via the Data Export Service, although this will not be always an option. Solutions via AppExchange are available to help customer with these particular requirements where the Data Export Service is not possible.

One workaround that can be employed is to have all "Content Files" shared to the user performing the export in this case the System Administrator. 
 

Решение


          Ways to share Content Files in Salesforce:
 

1. This can be done by the Content File owner in the UI by going to the File Detail Page and clicking on Sharing Settings and selecting the user where file needs to be shared with. More detailed information is available in Share Files with People in Salesforce Classic.


2. Above solution may not be always ideal specially when dealing with many files. An option is to use Data Loader to share the files to a particular user. Since you cannot use the Content Document Object to get the ID's, you will need to use another object to get the ContentDocumentID's.

Steps to Share Files Using Data Loader:

a.  In Data Loader, run an export operation on the ContentDocumentLink object. Make sure to include the ContentDocumentID field in your export.

Note: You will need to ensure that you are using a filter for a single LinkedEntityId or ContentDocumentId. If you are exporting Content Files from multiple records, you can use the sample SOQL Query in Data Loader below: 
 
In Data Loader, export ContentDocumentLink records to retrieve the ContentDocumentId for each file. The ContentDocumentLink object stores the relationship between files and the records they are attached to. Use the following SOQL query, replacing the example IDs with actual Salesforce record IDs:
 
 Select Id, LinkedEntityId, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN ('RecordID1','RecordID2')
 
b. Using the file you get from step a, you will only need the ContentDocumentID column. You may have duplicate ID's here since Files could be shared to multiple records/users. You can keep the file as is or remove the duplicates in the CSV file.

c. Once you have cleaned up the file above, prepare it for the "ContentDocumentLink" insert operation by adding the following Column Headers: LinkededEntityId and ShareType.

Values for the new Column Headers would be

*LinkededEntityId = UserID where you want the files to be shared
*Sharetype =

V (Viewer) — the user can view but not edit the file; 
 
C (Collaborator) — the user can view and edit the file;
 
I (Inferred) — permission is determined by the related record or library.


d. Using Data Loader, run an "Import" operation using the "ContentDocumentLink" Object.



Once the import is a success, the user where the Content Files were shared to will now be able to export all ContentDocuments with no problem via API and perform operations based on the "Sharetype" that was set.


Дополнительные ресурсы

Query All Files

Номер статьи базы знаний

000382063

 
Загрузка
Salesforce Help | Article