Import Content

Import Content

Content Document :

It Represents a document that has been uploaded to a library in Salesforce CRM Content or Salesforce Files. The maximum number of documents that can be published is 30,000,000. This object record you don’t have to create. It gets created when you create ContentVersion which is the child of ContentDocument.

Content Version:

Represents a specific version of a document in Salesforce CRM Content or Salesforce Files. In other words, this object stores document information similar to Attachment.

Import ContentDocument & ContentVersions

Prepare the CSV file to insert to the ContentVersion object

  • Create a CSV file with the below fields..
    Title – (Required) file name
    VersionData – (Required) complete path to the file you’re uploading from your local machine or drive
    Description – (Optional) link description or file
    PathOnClient – (Required) complete path to the file you’re uploading
    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 :

    • Setting FirstPublishLocationId is only applicable on insert of new files and the field does not accept updates
    • The Sharetype of the created ContentDocumentLink to the related record is Visible by Default

  • Open data loader and login
  • Select Insert and select Show all Salesforce objects
  • Select ContentVersion
  • Browse to your CSV file
  • Click Create or Edit a Map then select Auto-Match fields to columns
  • Click OK | Next | Finish

Create a CSV and perform an insert to the ContentDocumentLinkobject

  • You can use Data Loader for exporting 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
  • Create a CSV file with the following columns:
    • LinkedEntityID – (Required) ID of the related record that the file is associated with (Accounts or Opportunities)
    • ShareType – (Required) the permission granted to user. For valid values, see the ‘Description’ details for the field in the ContentDocumentLink | SOAP API Developer Guide
    • 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
  • Now Open Data Loader and click on Insert
  • Select the Show all Salesforce objects
  • Select ContentDocumentLink
  • Browse to your CSV file
  • Click Create or Edit a Map then select Auto-Match fields to columns
  • Click OK | Next | Finish

Some important Points :

    • While inserting the ContentVersion, create a new custom field to store the legacy content version Id and Content Document Id
    • Now, after inserting the ContentVersion export the data with the new fields that you created
    • While preparing the file for Content Document Link you can use VLOOKUP to get the New Content Document Id based on the Legacy Content Document Id