Export and Import Attachments from Salesforce to Dynamics CRM 2011

Zhen Yuwang, 20 May 2012

In my last post, I showed you how to migrate Notes from Sales Force into Microsoft Dynamics CRM 2011. The process to migrate attachments is quite similar, except we need to tick the Include images, documents and attachments option as shown in the screenshot below.
 Export and Import Attachments from Salesforce to Dynamic CRM 2011

When we click on Start Export, it will give us a ZIP file which we need to extract. The ZIP file includes an “Attachment.csv” file as well as an “Attachments” folder.

 Export and Import Attachments from Salesforce to Dynamic CRM 2011

Inside the “Attachments” folder, there will be a list of all the attachments that exist inside Sales Force. Note that they have special names and no file extension, so if we were to import the data into CRM, users will not be able to download the attachments because a file extension has not been provided.
 Export and Import Attachments from Salesforce to Dynamic CRM 2011

Inside the “Attachment.csv” file, we have an Id column which maps to the file name inside the “Attachments” folder.  We need to take the Name column and use this in order to rename the files in the “Attachments” folder. This can be done manually if we are only dealing with a few attachments, but for systems with a large number of attachments we would need to use a custom application to automate the process.
 Export and Import Attachments from Salesforce to Dynamic CRM 2011

We can also see that there are duplicates in the Name column so we need to append a unique number to the end of each duplicate file name in the “Attachments” folder.

    Export and Import Attachments from Salesforce to Dynamic CRM 2011

Export and Import Attachments from Salesforce to Dynamic CRM 2011

Next we need to create a file called “note.csv” with the columns shown in the screenshot below:
 Export and Import Attachments from Salesforce to Dynamic CRM 2011

The “AccountId” allows us to link our note or attachment to an Account in CRM.

Lastly, take the modified attachment files and place them into the “Attachments” folder. Place “note.csv” inside the same directory as the “Attachments” folder and ZIP the two items into a compressed file called “Notes and attachments.zip”.

Export and Import Attachments from Salesforce to Dynamic CRM 2011

Import the ZIP file into CRM. The “UserId” field can be mapped to the “OwnerId”.

 Export and Import Attachments from Salesforce to Dynamic CRM 2011

After the import is complete, we can see the result by opening up an Account record and viewing the Notes and Attachments. CRM users can now open up the attached documents as a correct file extension has been provided.
 Export and Import Attachments from Salesforce to Dynamic CRM 2011