Monday, June 25, 2012

Importing notes attachments in CRM2011

Recently I came across a situation, where I have to move an entity records and file attachments from one deployment to another.I have done this in CRM 4.0 using data migration wizard. I was thinking if I can do the same using “Data Import” tool in CRM2011.
After some searching on Google, I found few dynamic forums and a LinkedIn group that were very helpful. Here is a link to the LinkedIn group. Here is scenario. I have 2 separate deployments of CRM2011. They are not connected to each other. I need to move the accounts and file attachments (notes) from one deployment to another.
The solution is consists of 2 parts
  1. On CRM deployment 1, I will write some custom code to create a zip file that will contain 2 CSV file and “Attachments” folder containing all the attachments.
  2. On CRM deployment 2. I will use built-in “Data Import” tool to import this zip file into the system.

Creation of Zip files

In this blog, I won’t be writing any custom code to create a zip file but will explain the structure of zip file.I have created a folder named “Import”. In “Import” folder, I have created 2 files and folder as shown in the screen shot.
image
The account.csv file will look like the following screen
image
The  note.csv will like the following screen.
image
The fieldnames “File Name”, “PhysicalFileName” and “Regarding” are very important here. They are important to import the attachments and linking to the proper account records.
  • Column “Filename” will be mapped to “FileName” field on the notes entity.
  • Column “PhysicalFileName” be mapped to the “Document” field on the notes entity.
  • Column “Regarding” will be mapped to the “Regarding” field in the notes entity.
Attachments folder will contain all the attachments files. Just make sure that the "PhysicalFileName” of the files are unique. If I am creating this zip file through code then I may add the account number as prefix to the files.
Now the next step will be to zip this “Import” folder into “Import.zip” file.

Importing the zip file

Now take this “Import.zip” file to the second deployment and import the file using “Data Import” tool. Here are the steps:
image
image
image
image
If the names of CSV files match the crm entities, “Data Import” wizard will map them to the appropriate CRM entities as shown the screen shot above.
image
Now here you can click on the entities and map the fields between your CSV files and CRM entities. I am going to map the notes entity fields in the next step

image
Make sure these fields are mapped as shown in the above screen shot.

image
image
If you are going to use this process on regular basis, save the data map by providing a “Data Map Name” highlighted by yellow in the above screen shot.

image
Click on finish. Check the record on completion of the import process.

I have attached the sample zip file here. Download it and import into your system to test it.

10 comments:

  1. That's great post... I didn't know we can do this in dynamics. Great work Amreek.

    ReplyDelete
    Replies
    1. Thanks mate. You are reading all my blog.

      Delete
  2. Microsoft Dynamics CRM training will help you manage and prioritize your business goals, customize.we teach MS Dynamics CRM training and class available at Hyderabad.

    ReplyDelete
  3. Hi MR. Singh i am very appropriate to you with this solved problems thank a lot to share this work to all all the best
    Thank you

    ReplyDelete
  4. Dear Amreek,
    Is this only for new leads?
    When i'm trying to do the same procedure on existing leads, it keeps telling me "Failed: A duplicate lookup reference was found. Error code:0X80040352 .
    Please advice !
    Thanks
    Elie

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. "Duplicate reference was found" will only occur if the import process find more than one record with the same name or leads in your case. To edit the leads, they should be exported with the option to re-import them.

    ReplyDelete