How to import files to Salesforce?

Hello #Trailblazers,

In our previous blog, we talked about how to import the files and notes from Salesforce org. Now, once the import is complete it’s time to export those to another related or unrelated salesforce org.

From the previous post here is how your folder will be looking like

  1. ContentVersion folder will contain all the files, notes, & document content which needs to uploaded.
  2. ContentVersion csv/excel file will contains all the parameters like OwnerId, Version, Title, and etc.

Prepare the CSV file to insert ContentVersion

To insert the files/document, we need to insert ContentVersion so the first thing is to prepare a file to CSV for inserting the ContentVersion.

To prepare the file you need to open the ContentVersion CSV file. Remove Everything and keep the below column only

  1. Id
  2. ContentDocumentId
  3. Title
  4. Description
  5. PathOnClient

Add one additional Column name it Content

Now go to the folder location where your files are and open the ContentVersion folder and copy the location. Refer below image

Now, go to the Content Column that you have added and use below formula “=”C:\Users\Amit Singh\Desktop\File Import\ContentVersion\”&A2″ Where

  1. “C:\Users\Amit Singh\Desktop\File Import\ContentVersion\” Location to your content version folder
  2. A2 is the Id coulumn.

Now your file is ready and looks like below

Use Data loader to insert the content version record

Open data loader, login, and insert Content Version record.

Here is the Mapping

You can open the success file and column 1 ( Id as header ) is your new Content Version Id. Using this new ContentVersion Id you can query Content Document Id

Now prepare the success file with a new Column “LinkedEntityId” which will represent the Record Id which can be a standard or custom object or user record id.

Now insert the content document link

Hurray, Now you have successfully inserted the files into your Salesforce environment.

Some important Points

  1. While inserting the ContentVersion, create a new custom field to store the legacy content version Id and Content Document Id
  2. Now, after inserting the ContentVersion export the data with the new fields that you created
  3. 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
Amit Singh
Amit Singh

Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion

Articles: 299

Newsletter Updates

Enter your email address below and subscribe to our newsletter

5 Comments

      • Okay! Quick question if we have 60,000 files and attachments related to different objects like cases and accounts and opportunities . i exported them first from source and trying to load them target org. First i will load content version along with content path. after loading I will take that success file .which is having content document id . next step would be add LinkedEntity id to that file. do we have to get those linkedEnity id’s from source (or) target? (target doesn’t have the files attached to those records ) . Do we have to manually check record id of each file and match that to content document id? I am confused here ? please advise me

        Thank you !

        • Normally, when you are migrating the files from one org to another org then most of the cases you also migrate the Records and while migrating the records store the source org record id in a field. Now as you have target org record Id and source org record Id you can easily find the LinkedEntity Id. This is quite tricky because if the records are already there in target org then finding the correct LinkedEntity id for the files is kind of very tough.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Panther Schools

Subscribe now to keep reading and get access to the full archive.

Continue reading