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
- ContentVersion folder will contain all the files, notes, & document content which needs to uploaded.
- 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
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
- “C:\Users\Amit Singh\Desktop\File Import\ContentVersion\” Location to your content version folder
- 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
- 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