Dynamics 365: An error has occurred opening field properties


I came across a strange issue within Dynamics 365 that I’d never seen before this week. A customer had made updates to the Status Reason (statuscode) field on the Order entity and after the change was saved and published we could no longer open the field properties for the field from the customization area. Trying to open the Status Reason gave the following error:

Error

An error has occurred.

Try this action again. If the problem continues, check the Microsoft Dynamics 365 Community for solutions or contact your organization’s Microsoft Dynamics 365 Administrator. Finally, you can contact Microsoft Support.

open-dynamics-365-field-properties-error-message

It seems that after the change was published, the Status Reason field was corrupted. To make matters worse the Order form would no longer open either. Downloading the log file from the form error gave the following information:

Unhandled Exception: System.ServiceModel.FaultException1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.at Microsoft.Crm.Application.InlineEdit.JsonWrapperFactory.CreateForStatusAttribute(StatusAttributeMetadata attributeMetadata, String entityLogicalName)at Microsoft.Crm.Application.InlineEdit.JsonWrapperFactory.Create(AttributeMetadata attributeMetadata, String entityLogicalName)

<ErrorCode>-2147220970</ErrorCode>

<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />

<Message>System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---&gt; System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Crm.Application.InlineEdit.JsonWrapperFactory.CreateForStatusAttribute(StatusAttributeMetadata attributeMetadata, String entityLogicalName) at Microsoft.Crm.Application.InlineEdit.JsonWrapperFactory.Create(AttributeMetadata attributeMetadata, String entityLogicalName)  at Microsoft.Crm.Application.InlineEdit.JsonWrapperFactory.CreateEntityWrapper(Int32 entityTypeCode, String formId, ICollection1 attributesOnForm, ICollection`1 unboundControlsOnForm)at Microsoft.Crm.Application.InlineEdit.ReadFormDataBuilder.RetrieveFormattedEntityMetadata() at Microsoft.Crm.Application.Pages.Common.ReadLayoutPage.WriteEntityMetadata(TextWriter writer) at Microsoft.Crm.Application.Pages.Common.ReadLayoutPage.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously): Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #F865F716</Message>

The following information from the error stood out to me and confirmed that it was something to do with the status:

CreateForStatusAttribute(StatusAttributeMetadata attributeMetadata, String entityLogicalName)

How to fix it

Since there was no chance of opening the Status Reason field from the customization area to fix it, the only option was to export the metadata and fix things via XML.

Examining the XML everything seemed Ok and the defaults for each status where legit values within the status reason and I could spot nothing wrong with the status reason options.

To fix it I exported the same fields from an unmodified version for Dynamics 365 and replaced the <optionset> attributes for both the Status and Status Reason fields in my file.

The steps below outline the process I took to resolved it:

  1. Add the Status and Status reason fields for the problematic entity into a Solution and export it.
  2. Unzip the file and open Customizations.xml within a text / XML editor
  3. Do the same process from an unmodified Dynamics 365 system. Note: I signed up for a trial version and did it from there.
  4. Replace the <optionset> attribute for the salesorder_statecode field with the values from the unmodified system
  5. Replace the <optionset> attribute for the salesorder_statuscode field with the values from the unmodified system
  6. Zip the modified customizations.xml and all other associated files
  7. Import and publish the new zip file

Once the changes have been published, refresh your browser cache and retry opening the form and the Status Reason field. Once confirmed everything is working again, retry the customizations.

FYI: Here are the values I used to replace the <optionset> attributes on the Order (salesorder) entity

salesorder_statecode:

salesorder_statuscode:

Good luck and feel free to comment if you have any issues.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts