Search code examples
dynamics-crmdynamics-crm-4

CRM 4.0 Throwing Exception during Publish


I am trying to publish the Account entity which I imported from another tenant and am receiving the following message in the trace logs:

Error: Object reference not set to an instance of an object.
Error Message: Object reference not set to an instance of an object.
Source File: Not available
Line Number: Not available
Request URL: http://crm1.blablabl.com/tenant/AppWebServices/SystemCustomization.asmx
Stack Trace Info: [NullReferenceException: Object reference not set to an instance of an object.]
   at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderAllLanguages.LoadMetadataLabel(Int32 entityType, String attributeName, ExecutionContext context)
   at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoader.LoadCellLabel(Guid cellObjectId, String cellObjectColumnName, Int32 objectType, String attributeName, ExecutionContext context)
   at Microsoft.Crm.ObjectModel.OrganizationUIService.InsertFormLabels(IBusinessEntity entity, ILabelLoader labelLoader, ExecutionContext context)
   at Microsoft.Crm.ObjectModel.OrganizationUIService.RetrieveMultipleWithAllLanguages(EntityExpression entityExpression, ExecutionContext context)
   at Microsoft.Crm.Metadata.OrganizationUIHelper.RetrieveInProductionHelper(Int32 objectTypeCode, ExecutionContext context)
   at Microsoft.Crm.Metadata.UsageHelper.CheckForms(Guid attributeId, DynamicMetadataCache mdCache, ExecutionContext context)
   at Microsoft.Crm.Metadata.UsageHelper.GetAttributeUsageInfo(Guid attributeId, Guid relationshipId, DynamicMetadataCache mdCache, ExecutionContext context)
   at Microsoft.Crm.Metadata.UsageHelper.GetEntityUsageInfo(Guid entityId, DynamicMetadataCache mdCache, ExecutionContext context)
   at Microsoft.Crm.Metadata.EntityService.GetUsageInfo(Guid entityId, ExecutionContext context)
   at Microsoft.Crm.Metadata.EntityService.GetUsageInfo(Guid entityId)
   at Microsoft.Crm.Application.WebServices.SystemCustomization.EntityDelete.Execute(IUser user, Guid entityId)
   at Microsoft.Crm.Application.WebServices.SystemCustomization.SystemCustomization.DeleteEntity(Guid entityId)

Solution

  • Figured out my own solution:

    Account code has an entity type of 1 - so if you run the following query on your CRM database:

    SELECT  * FROM [MYTENANT_MSCRM].[dbo].[OrganizationUIBase] where [ObjectTypeCode] = 1
    

    You should see 2 rows which represent a published and unpublished form definition.

    There is an issue with EITHER of these forms (yes there can be a problem with the published form which will prevent you from publishing a valid new form). What you need to do is look at the FormXml field in each row for the following:

    • Cells with fields that don't exist
    • Cells with relationships that no longer exist

    You can also try a process of elimination. Remove one cell at a time, update BOTH records with the same FormXML, and try to publish again.

    It may take some time, but this will solve your problem.