onsdag 9 juli 2014

Upgrade problems from CRM 4.0 to CRM 2013

I have currently been working on an upgrade from CRM 4.0 to CRM 2013 for one of our customers and ran into som unexpected problem when doing the final step of the upgrade from CRM 2011 CRM 2013.

To begin with, when you're doing an upgrade like this, you won't be able to retain any of the code since the JS syntax has changed as well as how you write plugins. This was the first mission which I thought was going to be easiest to do after upgrading the organization to CRM 2011 since all JS libraries are put into web resources and are easier to find. 

At first I couldn't upgrade the organization to CRM 2011 but I thought that if I imported it to our CRM 4.0 server it might be a bit more compliant, possibly due to the fact that we have a higher roll up on that server than the production server that we got the db from. After a bounce on our CRM 4.0 server it imported neatly into CRM 2011.

 The thing that happened then was that I couldn't remove the web resource with an error message saying that it could not find the assembly <name>.dll. It didn't matter if I put the assembly in the assembly folder on the server as it was present on the system I was migrating from I still got the error. It was also impossible to unregister the assemblies with the same error message.
The solution of that problem was to unregister the plugins in CRM 4.0 and do another import to CRM 2011 which worked fine.

Now, after removing all code I did a db backup and restore to the CRM 2013 server running UR2 and tried to import the organization there which gave me the following error:


22:00:14|   Info| Applying slipstream dbUpdates to organization.  Id=82fd6726-2701-e411-960f-00155d0a8302, UniqueName=crmorg.
22:01:37|   Info| CrmAction execution time; InstallDatabaseUpdatesAction; 00:01:23.4180924
22:01:37|  Error| Installer Complete: OrganizationUpgrader - Error encountered
22:01:37|  Error| Exception occured during Microsoft.Crm.Tools.Admin.OrganizationUpgrader: Error.ActionFailed Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction
InnerException:
System.Data.SqlClient.SqlException (0x80131904): Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.



This wasn't particularly helpful. After a few tries on different servers running different versions of SQL Server for example I still had the same error. Then my colleague pointed me to Chris Gognettas blog, which again was the saviour of the day.

It appears that at least in UR2 of CRM 2013 there's a check of something which happens to fail if the upgrade from CRM 4.0 to CRM 2011 happened within 24 hours of the upgrade to CRM 2013 you get this error so if you're in a hurry you need to change the datetime field pointed out in Chris' blog, this is an unsupported action so be sure to take backups before you start.

Rickard Norström
Developer at CRM-Konsulterna
www.crmkonsulterna.se