Skip to main content

XrmToolBox: AutoNumberUpdater - new StateCode filter

Migration of CRM 4.0 to CRM 2011

In this blog I will show you all the steps it took for me to migrate an CRM 4.0 organization to CRM 2011:

1. Created backups of my CRM 4.0 organization DB and report server DB
2. Imported backups on target environment / SQL Server
3. Connected report server instance to my imported CRMReports DB
4. Restored the SSRS encryption key (you need a password for your encryption key file)
5. Within the CRMReports DB in the table "Key" I deleted multiple entries so that it should look like this:
6. Started the Deployment Manager:
7. Started to import organization:

8. Selected my restored CRM 4.0 organization DB
9. Finished auto-mapping of AD-users and replaced one of the old CRM administrator accounts with my current new administrator account (might not be important for you).
10. Clicked next and started the migration.
11. Error appeared:

12:42:11| Error| Exception occured during Microsoft.Crm.Tools.Admin.OrganizationUpgrader: Fehler bei der Aktion Microsoft.Crm.Tools.Admin.UpgradeDatabaseAction.
InnerException:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'XPKLocalizedLabel'. Cannot insert duplicate key in object 'MetadataSchema.LocalizedLabel'.

12. SQL-Profiler identified the following entry:

Error: 2627, Severity: 14, State: 1 => Siehe Fehlermeldung oben.
SQL Statement:
exec sp_executesql N'INSERT INTO [LocalizedLabel] ( [LocalizedLabelId],
[LanguageId], [ObjectId], [ObjectColumnName], [Label], [LabelTypeCode], [ComponentState], [SolutionId], [OverwriteTime] ) VALUES ( @LocalizedLabelId,
@LanguageId, @ObjectId, @ObjectColumnName, @Label,
@LabelTypeCode, @ComponentState, @SolutionId,
@OverwriteTime )',N'@LocalizedLabelId uniqueidentifier,@LanguageId int,@ObjectId uniqueidentifier,@ObjectColumnName nvarchar(11),@Label nvarchar(79),@LabelTypeCode int,@ComponentState int,@SolutionId uniqueidentifier,@OverwriteTime datetime',@LocalizedLabelId='1F9A4FA5-C029-4F7E-B2C2-2C63194C3D11',@LanguageId=1031,@ObjectId='B1C70485-BA33-4C5F-8710-5446E3F68CA7',@ObjectColumnName=N'Description',@Label=N'Organisationseinstellungen, die in der Organisationsdatenbank gespeichert sind.',@LabelTypeCode=1,@ComponentState=0,@SolutionId='FD140AAD-4DF4-11DD-BD17-0019B9312238',@OverwriteTime='1900-01-01 00:00:00'

A search in Google gave me this:
Solution is to query the following statement:
UPDATE [Organisation_MSCRM].[MetadataSchema].[LocalizedLabel]

SET [LanguageId] = 1031
WHERE [ObjectId]='B1C70485-BA33-4C5F-8710-5446E3F68CA7'

13. After this error I had to restore my old DB because the migration stopped at this point.
       I restored the DB with the "WITH REPLACE" option.
14. I had to repeat everything from step 6 and prepare the DB with the statement above before starting the migration again.
15. After doing this the import went through almost successfull.

I got the following error message:Performing GrantServiceAccountAccess on SqlServerName MUCDEVCRMDB01 where SqlServerMachineName=MUCDEVCRMDB01,


reportServerUrl=http://mucdevcrmdb01/reportserver

20:21:45
Error
An error occurred when trying import and upgrade organization database MUCDEVCRMDB01.Alegri_MSCRM:

System.Data.SqlClient.SqlException (0x80131904): The login already has an account under a different user name.

This message is called in the following method found in the stacktrace:
Microsoft.Crm.Setup.Server.Utility.SqlUtility.GrantSrsServiceAccountAccess
Microsoft.Crm.Setup.Database.Helpers.GrantCrmReaderAccessToNetworkService
Microsoft.Crm.Setup.Database.Helpers.GrantCrmReaderAccess
Microsoft.Crm.Setup.Database.DatabaseUtility.CreateUser
Microsoft.Crm.Setup.Database.SharedDatabaseUtility.CreateUser  ======> ERROR


After some time of research I found out that CRM tries to add a user account to the SQL Server or CRM DB which was already there and existing.

As this was the only reason of the migration to fail I continued with a workaround (see next steps).

16. As the import/migration was interrupted through the error above the imported organization had the Status(State) of "Pending". This means the import was basically successfull but could not be finished and activated.

17. Workaround: manual activation of the organization
- Opened MS SQL Management Studio
- Opened the MSCRM_CONFIG DB
- Opened the table dbo.Organizisation in Edit-mode.
- Went to the row where my organization was and changed the State from 2 (pending) to 1 (activated).
- Back in the deployment manager I hit the "Refresh"-button and there you go -> the organization is activated.
- To make sure the manual activation was done right I disabled the organization via the UI and reactivated it because I stil don't know if with this action other modifications than the change of the State-column are happening.


18. Voilá the migration was successfully done and my CRM 4.0 organization is now running under CRM 2011.

(19.) Next steps would be to verify if all plugins, customizations (Javascript, custom webs) and reports are still working. In the meantime, I was able to fix some issues with custom webs and plugins. But this would be material for another blog.

Comments

  1. Do you have Customized Reports?
    How Can I Import my Customized Reports?

    ReplyDelete
  2. We had customized reports. They were migrated in the migration process. Otherwise you need to export the RDLs and import them later manually or via custom code.

    ReplyDelete

Post a Comment

Popular posts from this blog

Yet Another Address Autocomplete PCF Control–powered by Bing

In this blog post I will not go into detail in how to install all the pre-requisites that are required to build and run PCF controls. My goal was to build a new PCF control and get into coding of PCF controls as fast as possible. Here are a few links to articles that will help you installing the pre-requisites (Microsoft PowerApps CLI)  https://docs.microsoft.com/en-us/powerapps/developer/component-framework/get-powerapps-cli Other good references to get into this topic: https://toddbaginski.com/blog/how-to-create-a-powerapps-pcf-control/ https://docs.microsoft.com/en-us/powerapps/developer/component-framework/create-custom-controls-using-pcf I looked through the Guido Preite’s https://pcf.gallery/ which will help you find appropriate use cases / examples for your own needs. It did not take very long to find a simple example to start with: Andrew Butenko's https://pcf.gallery/address-autocomplete/ A few moments later I had the idea to create yet another address autocomplete...

Regarding SPFieldMultiLineText (Add HTML/URL content to a field) programmatically

I recently tried so set some HTML content in a SharePoint list column of type SPFieldMultiLineText. My first approach was this piece of code: SPFieldMultiLineText field = item.Fields.GetFieldByInternalName( "Associated Documents" ) as SPFieldMultiLineText; StringBuilder docList = new StringBuilder(); docList.Append( " " ); foreach (DataRow docRow in addDocs) { DataRow[] parent = dr.Table.DataSet.Tables[0].Select( "DOK_ID=" + docRow[ "DOK_MGD_ID" ].ToString()); if (parent != null && parent.Length > 0) { docList.AppendFormat( " {1} " , parent[0][ "FilePath" ].ToString(), parent[0][ "Title" ].ToString()); } } if (docList.Length > 0) { // remove trailing tag docList.Remove(docList.Length-5, 5); } docList.Append( " " ); string newValue = docList.ToString(); item[field.Title] = newValue; What this code does is to get all associated documents to the main document and to add these docu...

CRM 2016 SP1: Solution import failed with Solution With Id = 12ac16ec-41d5-1685-a230-0b1c31499250 Does Not Exist

Importing Solutions with the upgrade solution (holding solution) option is still not stable with CRM 2016 SP1 On-Premise. Ronald Lemmon already posted the same issue on his blog: http://ronaldlemmen.blogspot.de/2015/11/solution-with-id-86ac16ec-41d7-4685.html I expected it to be fixed with SP1 but it is still happening every now and then. With this query and the solution id (guid) of the error message you are able to find records in the ProcessTriggerBase table that reference the guid of a failed import from a holding solution that is not existing in the system anymore. select * from ProcessTriggerBase where solutionid = 'YOUR_SOLUTION_GUID' Due to this reference to a solution id not existing in the system you will not be able to import a new version of the target solution to be updated. What I did and this is probably not a supported solution is to update the guid to the actual target solution that is currently deployed in the system. To find out the id of ...