I recently had the joyous job of migrating some of the attachments from one org to another. The use case was a business unit spin-off into a new SFDC org. As such, unlike many migrations, only a subset of the data from the source org had to be moved to the target org.
As the SFDC doc (V36) states, Data Loader can not be used to export Attachment bodies. The SFDC suggestion is to use the Weekly Export feature. This suggestion was impractical as the org had tens of thousands if not more Attachments and I had previously determined that there were only 8000 or so Attachments that needed to be migrated. An enormous CSV file would be created that would be difficult to correctly manipulate in Excel.
So – my solution was to use the handy (free) tool, FileExporter, available on AppExchange.
Although AppExchange states a date of 2010, the tool has received updates from the developer – Ezra Konigsberg. Read the installation instructions carefully. Note that it is a Windows only solution. You have to use an older version of Data Loader (17) and update the security certificate. Ezra goes into great detail on how to do this in the ReadMe for FileExporter.
Another useful summary of the process of attachment migration is this post from West Monroe Associates, a most concise description of the process.
So, how did it go?
By default, FileExporter will download all of the org’s Attachments. Since I only wanted some Attachments, I edited the line in the beans.xml file as Ezra suggested to be like the following
<!ENTITY whereClause "CreatedDate>2014-09-09T00:00:00.000Z and parentId IN (select id from Account where type = 'Foo')">
to get the Account attachments I needed. Then, for the Case attachments, I did a second pass through FileExporter with this beans.xml file:
<!ENTITY whereClause "CreatedDate>2014-09-09T00:00:00.000Z and parentId IN (select id from Case where account.type = 'Foo')">
and so on for the Attachments on the other relevant SObjects (Opportunity, EmailMessage, etc)
FileExporter runs quite quickly although when I did the Case Attachments (over 7000), it was still running when I went to bed but, upon wakening, FileExporter had downloaded all the files when I woke up (home DSL connection).
- If the source file has an invalid Windows file name character in the Attachment name (in my use case it was a colon (:) ), FileExporter downloads the file with the name of theSourceSfdcOrgAttachmentId and no file extension. The file can’t be opened in Windows without telling Windows what program to use. Fortunately, this was not relevant to me as I was uploading the file into the target org and I just needed to adjust the value of the Body column to refer to the file name as exported, not one that resembled the normal pattern: theSourceSfdcOrgAttachmentId#theSourceSFDCFilename.ext. I contacted Ezra and he said he would handle colons in a future release (he handles other invalid Windows file name characters already like ‘&’).
- During upload via Data Loader, I received Java Heap error. Fortunately, SFDC Help had the answer with two workarounds. I simply adjusted the size of the Data Loader batch to ‘1’, resubmitted the job and went off to do other things.