A Guide to Migrating from CRM 2011 to CRM Online

It is an interesting time to be involved with Microsoft Dynamics CRM. Many people will be familiar with the main versions in use today – CRM v4, CRM 2011 and, of course, CRM Online. Adding to these will be the new release scheduled for the autumn, CRM 2013.

Being on the frontlines of the Dynamics world we are encountering a lot of companies interested in migrating from one version of CRM to another; and many people are looking for guidance on migrating their v4 organisation to 2011 or from v4 to Online. In our opinion, CRM Online is the way forward and that’s the impression we get from Microsoft as well. For some, CRM Online is simply not an option for various reasons, but for those who can use it, we think you should.

The upgrade path from CRM v4 to 2011 is fairly straightforward and there is plenty of good information already on the web for helping with any issues that are encountered. However, there is less available information regarding how to migrate from CRM 2011 to CRM Online and because of this we wanted to offer our own rough guide to successfully achieving this migration. In this post we will describe some of the challenges faced, the solutions found and, most importantly, some of the rewards that moving to CRM Online will bring.

At the time of writing there was still no recommended approach from Microsoft to migrate a CRM 2011 organisation to CRM Online. Sending them a backup of your SQL database would be handy but unfortunately this is not possible. Instead, we must export the data from 2011 and import it to Online. This means all the obvious entities like Accounts, Contacts, Leads, and the not so obvious entities like ActivityMimeAttachments and ActivityPartys. Your best option for performing this import/export is a third party tool, such as:

  • CRM Connector/Adapter (Microsoft) – Free, but difficult to use.
  • ALMToolkit (AdxStudios) – Free Trial – Good option, handles most of the heavy lifting.
  • Echo (Synchronicity) – Trial available – We haven’t used this one, so can’t comment on it.

A third party tool will likely do much of the work, potentially all, if you’re willing to pay! We used the ALMToolkit and encountered the following challenges:

Unresolved email addresses
You will likely have experienced this issue before: you open an email and some of the email addresses in the To, From, Cc or Bcc fields are in red and underlined. This means CRM can’t resolve the address to a record. In SQL this address is held as an ActivityParty.

To get around this, custom code had to be written to create the ActivityParty records in CRM Online. The code is too long to post but below are a few useful snippets:

  1. Here we are retrieving all the emails from the source organisation and looping through them to check for unresolved parties:
  2. records = xrmSource.RetrieveMultiple(pagequery);
    //Loop through each email checking for unresolved addresses
    for (int i = 0; i < records.Entities.Count(); i++)
      Email ap = (Email)records[i];
      //Check if the email (activity) has any unresolved addresses (look for nulls)
      List partyList = (from a in xrmSource.ActivityPartySet
                                        where a.ActivityId.Id == ap.ActivityId
                                        && a.PartyId == null
                                        select new ActivityParty
                                          ParticipationTypeMask = a.ParticipationTypeMask,
                                          AddressUsed = a.AddressUsed,
                                          ActivityId = a.ActivityId
  3. After identifying all the emails with unresolved addresses we need to loop through them and find the matching email in CRM Online. Remember that after the emails have been migrated they will have different GUIDs in CRM Online compared to the source CRM 2011 organisation. To find the matching email we can use the following:
  4. //Get the matching email in the destination org
    List emailInDestination = (from a in xrmDestination.EmailSet
                                      where a.Subject == ap.Subject
                                      && a.Sender == ap.Sender
                                      && a.ToRecipients == ap.ToRecipients
                                      && a.MessageId == ap.MessageId
                                      select new Email
                                       ActivityId = a.ActivityId,
                                       Subject = a.Subject,
                                       MessageId = a.MessageId,
                                       Sender = a.Sender,
                                       ToRecipients = a.ToRecipients,
                                       StatusCode = a.StatusCode,
                                       To = a.To,
                                       From = a.From,
                                       Cc = a.Cc,
                                       Bcc = a.Bcc
  5. When the matching email is found in CRM Online it’s then time to add the unresolved address, which could be the From, To, Cc or Bcc. In the example below it’s the From address:
//Create a new ActivityParty
var newActivityParty = new Xrm.ActivityParty
      AddressUsed = unresolvedParty.AddressUsed,
      ParticipationTypeMask = unresolvedParty.ParticipationTypeMask

//FROM field
if (unresolvedParty.ParticipationTypeMask == 1)
     //Get the current list of partys
     List originalList = emailInDraft.From.ToList();

     //Add the unresolved address to the list

     //Replace the FROM list
     emailInDraft.Attributes.Add("from", originalList.ToArray()); 

//Update the email and save the changes

When migrating data using the ALMToolkit you have to specify an account with which the data will be migrated. This account will become the owner of the records it migrates, which can be an issue for some businesses. To solve this you need to reassign all the records after they are moved back to the correct owners, which could be a User or a Team. In this instance, once again custom code is required to handle this as you could be dealing with thousands of records.

It is important to highlight that before and after updating an email you must set its status. It must be in Draft for it to be updated and then the status reverted back to its original value after the update. The code below will update the status of an email to Draft:

//To update the email it must be in Draft status
EntityReference moniker = new EntityReference();

moniker.LogicalName = "email";
moniker.Id = (Guid)email.ActivityId;

Guid emailID = email.Id;

SetStateRequest request = new SetStateRequest();
request.EntityMoniker = moniker;
request.State = new OptionSetValue(0); //Open
request.Status = new OptionSetValue(1); //Draft

//Put the email into Draft status
SetStateResponse response = (SetStateResponse)xrmDestination.Execute(request);

Security Model
As CRM Online does not use Active Directory it is a little complicated when it comes to migrating Users. You can’t migrate Users from CRM 2011 to CRM Online but you can migrate AD accounts to Office 365. This is important because with CRM Online you don’t create Users through CRM any longer. You setup the Users in Office 365 and through the Office 365 management portal you assign them a CRM license. Once this is done they will appear in CRM a minute later. With the Users setup you then have to assign them the correct Security Roles and place them in the correct Teams.

These are steps which have to be done manually or with custom code. Again, there were a lot of records so some code is required to automate the process. The code shown below will loop through all records for all entities (which can be owned); and on each loop the code below is used to get the owner of the record in the source CRM 2011 organisation and then the matching User in the destination CRM Online organisation:

//Get the Owner details from source record
EntityReference ownerRef = (EntityReference)currentRecord.Attributes["ownerid"]; 

Entity ownerInDestination;

if (ownerRef.LogicalName == "systemuser")

SystemUser userInSource = (from u in xrmSource.SystemUserSet
                           where u.Id == ownerRef.Id
                           select new SystemUser
                           FirstName = u.FirstName,
                           LastName = u.LastName,
                           Id = u.Id

string fullName = userInSource.FirstName + " " + userInSource.LastName;

//Get owner from destination
ownerInDestination = (from u in xrmDestination.SystemUserSet
                      where u.FullName == fullName
                      select new SystemUser
                      Id = u.Id

Note: Similar code would be needed for Teams as well as Users.

Finally, when you are ready to reassign the record to the correct User the code below will do it:

//Assign the record to the correct owner
AssignRequest assign = new AssignRequest
Assignee = new EntityReference(ownerInDestination.LogicalName, ownerInDestination.Id),
Target = new EntityReference(editedEntityName, currentRecord.Id)

AssignResponse response = (AssignResponse)xrmDestination.Execute(assign);

Email Router
This is the one that can be really confusing. After migrating to CRM Online there is no online equivalent of the Email Router! Sure, you can hook up your Outlook to CRM Online to send emails, but the businesses I have seen all use the Email Router to send automatic emails at specific times. This means you have to have the Email Router installed on one of your own servers/desktops to continue having the features it provides. Hopefully this will be rectified soon, but at the moment it’s your only option. By the way, the Email Router does work with Exchange Online.

There are a few challenges when moving to CRM Online, but doing so will mean saying goodbye to managing CRM servers and installing rollups which have been known to cause headaches. With CRM Online you will be upgraded to the new CRM 2013 version automatically early next year which is something else to keep in mind. If you migrate to CRM Online it might well be the last migration you ever do!

August 8, 2013


Email [email protected] with any questions you have pertaining to this course.

New CPE Accredited Courses Now Available for Dynamics AX, GP, and NAVEARN CREDITS TODAY