There are 3 main stages for org-to-org File migration:
- Exporting Files from the source org (Steps 1-2)
- Importing said Files to the target org (Steps 3-4)
- Relating the imported Files to existing data (Step 5) – this is where the bulk of the work will be!
Step 1
Use the Data Export function in Salesforce to export the Files. Check the box ‘Include Salesforce Files and Salesforce CRM Content document version’. You don’t need to export the actual data.
This creates one or more zip files. When you extract them, look out for the following:
ContentVersion folder (contains the Files so there may be more than one folder)
ContentVersion.csv (contains the ID of each File)
ContentDocumentLink.csv (contains the IDs to relate Files to records)
Step 2
Unzip the ContentVersion folder(s) into a single ContentVersion folder on your local drive.
Step 3
This is where you prepare to import the Files into the target org. Recreate the ContentVersion.csv file from Step 1 with:
| Title | (Required) – File name |
| Description | (Optional) |
| PathOnClient | (Required) – The path name of where you have stored the Files in Step 2(e.g. C:\Files\ContentVersionAll) |
| Version Data | (Required) – The PathOnClient, plus the file Name(e.g. C:\Files\ContentVersionAll\0680P000006N82BQAS – this is the File Name found in the ContentVersion folder) |
| I would also recommend creating an External ID field on the target ContentVersion object to hold the original Salesforce ID, as this will assist with relating records correctly further down the process. |
Step 4
Use the new ContentVersion.csv file to insert the Files into the target org ContentVersion object.
Step 5
Now that the Files have been imported to the target org, each File will have been allocated a new ContentDocumentID. This will now be used to link the File to the related records.
- From the target org, export the ContentVersion object using the same fields as in Step 3, plus the ContentDocumentID field
- Open the exported ContentVersion.csv file and the ContentDocumentLink.csv file from Step 1 (I would recommend keeping a copy of the original file in case you need to refer back to it)
Here’s the tricky bit. You now need reconstruct the ContentDocumentLink.csv file, using the IDs from the target org, which could be different to the IDs in the source org (if you have performed a data migration prior to this). This should be made simpler by using the External ID from Step 3 to match the records. Choose whichever method you are comfortable querying data with, e.g. lookups in Excel, MySQL queries or even MS Access. There is no ‘right’ application or method to use.
The new ContentDocumentLink.csv file (which you will then import into your target org), needs to be constructed as follows:
| ContentDocumentID | (Required) – From the import success file in Step 4, or the export in Step 5 |
| LinkedEntityID | (Required) – The record ID of the related record in your target org |
| ShareType | (Required) – The permission granted to user. For valid values, see the ‘Description’ details for the field in the ContentDocumentLink | SOAP API Developer Guide |
| 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 link above |
Renaming and Converting Chatter Content after exporting:
Now that you know how to migrate Files, you have probably gathered that moving anything other than Salesforce records can be a little complex. Another type of data you might want to migrate is Chatter Content. All those helpful internal interactions need to be backed up, or even migrated if you are moving to another system. If you have ever exported Chatter Files, Content and Attachments using the Weekly/Monthly Export Service before, you will probably know that everything comes out in an indecipherable fashion, and cannot be opened. Luckily, this article explains exactly what you need to do to convert your Chatter Content back to its original form, and make it usable outside of Salesforce.
This article is take from here. So all credit for this article goes to this site.
Please check below post if you want to convert attachment
Thanks this really helps a lot on file migration from one org to another org. i am able to import the files to my current org by following above steps. but there is one issue i am facing while opening the file in target sandbox it shows no preview available. i checked the file size is not large also its not a password-protected files.its happening for all the files. could you please guide why i am facing such issue.
Hi Swati,
Can you please share screenshot for the issue? You can email me how can I reach out to understand your issue.
Thanks,
Sandeep
Hi Sandeep, I’m also facing the same issue that Swati mentioned. while opening the file in target sandbox it shows no preview available. can you please give the solution
Im facing the same issue that Swati but I think that is because the files were migrated without file extension and I dont know why and I cant find a way to change the file extensions.
please let me know when we can connect on this
Hi Sandeep,
On Step 4, you mentioned to insert the files. Did you use Dataloader to insert files?
yes