Nov 16, 2016

Don't Break Your Dynamics CRM Online instance

Yes, Microsoft Dynamics CRM Online is a well-known and solid system. But I thought I should warn you that you can break it, using nothing but the SDK code, if you use it in a certain way.

In a migration job from an On-Premise install to an Online install, I was migrating tracked e-mails with attachments. From how I'd migrated other entities, I figured attachments would follow the same procedure: Import e-mails with their existing Ids, and import attachments, with their existing Ids, referencing the existing e-mail Ids. Boy, was I wrong.

Everything worked, meaning the service did not object to what I was doing to it, and browsing the activites online worked fine. Or so I thought. When looking closer, the attachments were there, but they were "invisible". The file name and files size were missing, and nothing showing up in the e-mail viewer.



So of course, my first action was to delete everything. A batch job to delete all e-mails, failed. That's strange... Well, try to delete the attachments from inside the e-mail viewer, then? The garbage can icon was there, and appeared to do some work when I clicked it. But no, it ended up in an error:

Now I was really getting unsure how to proceed, so I attempted to delete all accounts. Still no joy. Accounts were not getting deleted as long as they had e-mails with attachments connected to them! After a few attempts at this, and realizing there was no backup of the instance available, and worst of all, this was a production instance (but not yet in production), I connected with Microsoft Partner Support. It's now been a couple of weeks, and the problem is still not resolved.

I have since created a sandbox instance, and found out how to migrate e-mails with attachments. So, here's my solution (drumroll):

  • Get all e-mails from the source instance
  • For each e-mail in the source, create an upsert or an insert for each e-mail
  • Then, loop through the attachments, and do a create request for each
  • If you're doing this in batches, remember the maximum count for one batch is 1000 entities, so keep track of how many entities you're trying to push
Doing it this way has one downside that I've found, which is that pictures embedded in the e-mail no longer work, because the original guid is embedded in the e-mail source. Maybe someone somewhere will have a solution for this as well.

Hope you read this blog post before you do a failed e-mail migration like myself. If not - best of luck!


No comments:

Post a Comment