Loading

Insert files with Salesforce Data Loader

게시 일자: Oct 31, 2024
상세 설명

To create files using the Salesforce Data Loader, you will need to perform two tasks.  First, insert records as the ‘ContentVersion’ and then insert ‘ContentDocumentLink’ to associate it to records.
 

솔루션
 
Warning
Always back up your data before performing any data operation. See Export Backup Data from Salesforce or Export Data for more details. It is recommended to run a test with a small subset of records to ensure the operation was successful through manually opening and verifying that the corresponding records are correct in Salesforce.

 

1. Prepare a CSV and perform an Insert to the ContentVersion object.

 
  1. Create a CSV with the following columns:
 
  • Title - (Required) file name
 
  • Description - (Optional) file or link description
 
  • VersionData - (Required) The complete path to the file you're uploading from your local machine or drive. Files are converted to base64 encoding on upload. This action adds approximately 30% to the file size. Example: C:\Users\jdoe\Desktop\PictureFile.jpg
 
  • PathOnClient - (Required) The complete path to the file you're uploading from your local machine or drive. 
 
  • FirstPublishLocationId - (Optional) if you are only relating the File to a single record in Salesforce, populate this with the related record's Id. This automatically creates a ContentDocumentLink to associate the file to the related record to effectively skip the 'Prepare a CSV and perform an insert to the ContentDocumentLink object to associate Files to records' steps below.
 
Notes:
 
  1. Setting FirstPublishLocationId is only applicable on the insert of new files, and the field does not accept updates.
  2. The Sharetype of the created ContentDocumentLink to the related record is Visible by Default.
  3. For more information on the CSV fields described above, see the Data Loader Guide.
 
  1. Open and Configure Data Loader to use a 'Batch Size' of 1.
  2. Select Insert and select Show all Salesforce objects.
  3. Select ContentVersion.
  4. Browse to your CSV file.
  5. Click Create or Edit a Map then select Auto-Match fields to columns.
  6. Click OK | Next | Finish.


2. Prepare a CSV and perform an insert to the ContentDocumentLink object to associate Files to records


Use Data Loader to Export Data from the 'ContentVersion' object to get 'ContentDocumentId' for your newly created Files.


Note: If you specified FirstPublishLocationId on File insert, the following steps are only necessary to associate the newly created Files to additional records in Salesforce.
 
  1. Create a CSV file with the following columns:
 
  • LinkedEntityID - (Required) ID of the related record that the file is associated with (Accounts or Opportunities).
 
  • ContentDocumentID - (Required) ContentDocumentID from the exported ContentVersion file (starts with '069').
 
 
  • Visibility - (Optional) Specifies whether this file is available to all users, internal users, or shared user. Refer to the field's 'Description' details in the guide linked above.
 
  1. Open Data Loader and click Insert.
  2. Select the Show all Salesforce objects box.
  3. Select ContentDocumentLink.
  4. Browse to your CSV file.
  5. Click Create or Edit a Map then select Auto-Match fields to columns.
  6. Click OK | Next | Finish.
 
Knowledge 기사 번호

000382372

 
로드 중
Salesforce Help | Article