Here’s a little tip that, as I speak with customers/partners, I’m discovering isn’t well known. I will show you how to leverage features of the import process to the fact that import process allows you to build your entities much faster in Dynamic CRM 2011. It is one approach, but I would love to hear any you might have. The basic process is:
- Create entity
- Create option set fields
- Create relationships where necessary
- Import data and create the rest of the fields along the way
To get this to work without prefix side effects, make sure you follow the instructions in my Ensuring you are using your prefix everywhere post first. Let’s start with a very simple entity model:
I know, bad example, but I wasn’t feeling creative. To build this out we’re first going to create the Parent and Child entities:
NOTE: As a personal practice, I always clear out everything below the Options for Entity section of the form. You can always go back and add features later, but you can’t undo things that have the + sign next to them.
Technically, we could create the entity as part of the import process, but I prefer creating it explicitly because I have full control of the creation options. For Fields of type Option Set, you should create them in the entity ahead of time. In this example we are going to create a Blood Type field and create a new reusable option set with the values in the picture:
Technically, you can create option set fields during the import process, but they won’t be reusable. Therefore I always create them ahead of time. For other field types, we’ll create them during import. Now, let’s go ahead and create a 1:N relationship between the Parent and Child entity:
Technically, we could create the relationship during import, but I prefer creating it explicitly because I have full control of the options. Next, create two csv files that look like:
Parent.csv
Name,Date Of Birth,Blood Type
Parent1,11/05/2000,O+
Parent2,11/05/2000,A+
Parent3,11/05/2000,B-
Child.csv
Name,Date Of Birth,Blood Type,Parent
Kid1,11/05/2000,O+,Parent1
Kid2,11/05/2000,A+,Parent2
Kid3,11/05/2000,B-,Parent3
Now import Parent.csv:
Browse to the file and accept the defaults until you get to this screen:
As you can see Blood Type is already mapped to the option set we created. Map the Date Of Birth field:
Keep clicking the Next button until you get to the end and click the Submit button. The Import Data Wizard will create the remaining field and import the data. Now let’s get the Child entity set for import. Go ahead and create the Blood Type option set field for the Child entity like we did for the Parent, but this time reuse the existing option set. Now import the Child.csv file. You will have to create a new field for Date Of Birth, but Blood Type and Parent from the input file will have been auto mapped to the corresponding fields in the entity:
That’s it! I’ve shown a really simple example where we really only automated the creation of one field per entity. I did that to keep the walkthrough simple. I also walked through why I choose to still manually create option set fields and relationships. If you apply this technique to creating entities with say 10+ fields, you really start to appreciate the productivity gains of automating the field creation process. HTH