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
- 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
- Id
- ContentDocumentId
- Title
- Description
- 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
- “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
Thank you!!! This was very helpful.
Hi How do we get that linkentity ID in the target org ? please help me i got stuck around Link Entity ID
LinkedEntity Id is the record Id under which you will upload the files. And this is something you need to find what record you wanted to use as parent.
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.