Error: The object cannot be updated because it is read-only occurs when you try to revise or close a Quote in Microsoft Dynamics CRM 4.0


Symptoms


When you revise or close a Quote in Microsoft Dynamics CRM 4.0, you receive the following error message:

The object cannot be updated because it is read-only

The following information is part of the event: MSCRM Platform Error Report:

 >MSCRM Error Report:
--------------------------------------------------------------------------------------------------------
Error: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Error Number: 0x8004022E
Error Message: The entity cannot be updated because it is read-only.
Error Details: The entity cannot be updated because it is read-only.
Source File: Not available
Line Number: Not available
Request URL: http://localhost:5555/AdventureWorksCycle/sfa/quotes/edit.aspx?id={4B8CB804-B2C9-DE11-BD49-00155DF4750A}
Stack Trace Info: [CrmException: The entity cannot be updated because it is read-only.]
at Microsoft.Crm.ObjectModel.QOIService.Update(IBusinessEntity qoi, IBusinessEntity qoiPreImage, ExecutionContext context, Boolean calculatePrice)

Cause


This problem occurs because a customization on the OnLoad or OnSave events tries to update an attribute property.

Example:

The following Javascript code is used to update the Quote Name attribute on the OnLoad Event:

crmForm.all.name.DataValue = “Example”;
crmForm.all.name.Disabled = true;
crmForm.all.name.ForceSubmit = true;

Resolution


To resolve this problem, change the OnLoad or OnSave events to prevent the update action from being run on a disabled form. 

if (crmForm.FormType != 4)
{
crmForm.all.name.DataValue = “Example”;
crmForm.all.name.Disabled = true;
crmForm.all.name.ForceSubmit = true;
 }

More Information