I am getting and exception while trying to update an existing record in salesorderdetail entity. Below is the exception I am getting
"A validation error occurred. The value of 'salesorderstatecode' on record of type 'salesorderdetail' is outside the valid range."
The same code is working fine without any issues in our development and test environments. We are having the problem only in our production environment. We compared the meta data of salesorder and salesorderdetail entities and their attributes between test and production environments and could not find any differences.
Below is complete SOAP Fault message
<s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">An error occured while processing this request.</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>A validation error occurred. The value of 'salesorderstatecode' on record of type 'salesorderdetail' is outside the valid range.</Message><StackTrace>
 Server stack trace: 
 at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
 at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
 at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
 at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
 
 Exception rethrown at [0]: 
 at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
 at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
 at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)
 at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
 at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
 at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChange(OrganizationRequest request, IList`1 results)</StackTrace><Type>System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]</Type></InnerException><Message>An error occured while processing this request.</Message><StackTrace> at CrmPurchaseOrderProxy.UpdatePurchaseOrder(PurchaseOrder upsertPurchaseOrder) in C:\Users\CRM.ProxyService\CRM.ProxyService\CrmPurchaseOrderProxy.cs:line 342
 at SyncInvokeUpdatePurchaseOrder(Object , Object[] , Object[] )
 at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
 at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
 at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
 at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
 at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>Microsoft.Xrm.Sdk.SaveChangesException</Type></ExceptionDetail></detail></s:Fault>
I really appreciate communities help in resolving this critical production issue.