locked
Cannot change the StateCode of a Phone Call activity to Completed in CRM 3.0 RU 3 RRS feed

  • Question

  • I am trying to set the status of a Phone Call activity to "Completed" using the following code:

    ...

    SetStatePhoneCallRequest state = new SetStatePhoneCallRequest();
    state.PhoneCallState = PhoneCallState.Completed;
    state.PhoneCallStatus = 2;
    state.EntityId = newKey.Value;
    base.CrmService.Execute(state);

    ...

    This works on other CRM implementations but it fails on this specific CRM 3.0 RU 3 server.  The CRM trace reports the following information:

    [2010-04-06 16:51:31.9] Process: w3wp |Thread: 6812 |Category: Platform.Soap |User: 564d0467-dfb4-4b6a-8d13-a10826e8081d |Level: Verbose | SoapContext.DumpInfo
     at SoapContext.DumpInfo()
     at CrmSoapExtension.ProcessMessage(SoapMessage message)
     at SoapMessage.RunExtensions(SoapExtension[] extensions)
     at SoapServerProtocol.ReadParameters()
     at WebServiceHandler.Invoke()
     at WebServiceHandler.CoreProcessRequest()
     at SyncSessionlessHandler.ProcessRequest(HttpContext context)
     at CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
     at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
     at HttpApplication.ResumeSteps(Exception error)
     at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
     at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
     at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
     at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >SOAP Request:
    >URL:CrmService.asmx
    >HttpHeader:SOAPAction: http://schemas.microsoft.com/crm/2006/WebServices/Execute
    >
    >SOAP Xml:
    ><?xml version="1.0" encoding="utf-8"?>
    ><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    ><soap:Body>
    ><Request xsi:type="SetStatePhoneCallRequest" xmlns="http://schemas.microsoft.com/crm/2006/WebServices">
    ><EntityId>dcf1fce2-8b41-df11-9661-0003ff10150a</EntityId>
    ><PhoneCallState>Completed</PhoneCallState>
    ><PhoneCallStatus>2</PhoneCallStatus>
    ></Request>
    ></soap:Body>
    ></soap:Envelope>
    >
    [2010-04-06 16:51:32.4] Process: w3wp |Thread: 6812 |Category: Platform.Sdk |User: 564d0467-dfb4-4b6a-8d13-a10826e8081d |Level: Info | Request.ReadXml
     at Request.ReadXml(XmlReader reader)
     at XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)
     at XmlSerializationReader1.Read20_Execute()
     at ExecuteSerializer.Deserialize(XmlSerializationReader reader)
     at XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
     at XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events)
     at XmlSerializer.Deserialize(XmlReader xmlReader)
     at SoapServerProtocol.ReadParameters()
     at WebServiceHandler.Invoke()
     at WebServiceHandler.CoreProcessRequest()
     at SyncSessionlessHandler.ProcessRequest(HttpContext context)
     at CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
     at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
     at HttpApplication.ResumeSteps(Exception error)
     at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
     at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
     at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
     at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >Parsed request: SetStatePhoneCallRequest
    [2010-04-06 16:51:32.4] Process: w3wp |Thread: 6812 |Category: Exception |User: 564d0467-dfb4-4b6a-8d13-a10826e8081d |Level: Error | CrmArgumentException..ctor
     at CrmArgumentException..ctor(String message, String paramName, Int32 hResult)
     at StatusCodeValidator.Validate(EntityMetadata entityMetadata, Int32 stateCode, Int32 statusCode)
     at BusinessProcessObject.SetStateStatus(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context)
     at PhoneCallService.Microsoft.Crm.Sdk.IStateful.SetStateStatus(BusinessEntityMoniker , Int32 , Int32 , ExecutionContext )
     at RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
     at RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
     at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at LogicalMethodInfo.Invoke(Object target, Object[] values)
     at MethodDescription.ExecuteInterface(Object methodImplementation, Object[] inputParameters)
     at Request.Process()
     at CrmService.Execute(Request request)
     at RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
     at RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
     at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at LogicalMethodInfo.Invoke(Object target, Object[] values)
     at WebServiceHandler.Invoke()
     at WebServiceHandler.CoreProcessRequest()
     at SyncSessionlessHandler.ProcessRequest(HttpContext context)
     at CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
     at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
     at HttpApplication.ResumeSteps(Exception error)
     at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
     at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
     at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
     at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >Crm Exception: Message: -1 is not a valid state code on phonecall., ErrorCode: -2147187704, InnerException: System.ArgumentException: -1 is not a valid state code on phonecall.
    Parametername: stateCode
    [2010-04-06 16:51:32.4] Process: w3wp |Thread: 6812 |Category: Platform.Soap |User: 564d0467-dfb4-4b6a-8d13-a10826e8081d |Level: Warning | SoapContext.DumpErrorResponse
     at SoapContext.DumpErrorResponse(Stream responseStream, String url, String methodName)
     at CrmSoapExtension.ProcessMessage(SoapMessage message)
     at SoapMessage.RunExtensions(SoapExtension[] extensions)
     at SoapServerProtocol.WriteException(Exception e, Stream outputStream)
     at WebServiceHandler.WriteException(Exception e)
     at WebServiceHandler.Invoke()
     at WebServiceHandler.CoreProcessRequest()
     at SyncSessionlessHandler.ProcessRequest(HttpContext context)
     at CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
     at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
     at HttpApplication.ResumeSteps(Exception error)
     at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
     at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
     at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
     at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >SOAP Request failed:
    >Url:http://babtec30/MSCRMServices/2006/CrmService.asmx
    >MethodName:Execute
    >Response:
    ><?xml version="1.0" encoding="utf-8"?>
    ><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    >  <soap:Body>
    >    <soap:Fault>
    >      <faultcode>soap:Server</faultcode>
    >      <faultstring>System.Web.Services.Protocols.SoapException: Der Server konnte die Anforderung nicht verarbeiten. ---&gt; System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---&gt; Microsoft.Crm.CrmArgumentException: -1 is not a valid state code on phonecall. ---&gt; System.ArgumentException: -1 is not a valid state code on phonecall.
    >Parametername: stateCode
    >   --- Ende der internen Ausnahmestapelüberwachung ---
    >   at Microsoft.Crm.BusinessEntities.StatusCodeValidator.Validate(EntityMetadata entityMetadata, Int32 stateCode, Int32 statusCode)
    >   at Microsoft.Crm.BusinessEntities.BusinessProcessObject.SetStateStatus(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context)
    >   at Microsoft.Crm.ObjectModel.PhoneCallService.Microsoft.Crm.Sdk.IStateful.SetStateStatus(BusinessEntityMoniker , Int32 , Int32 , ExecutionContext )
    >   --- Ende der internen Ausnahmestapelüberwachung ---
    >   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
    >   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
    >   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    >   at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
    >   at Microsoft.Crm.Sdk.MethodDescription.ExecuteInterface(Object methodImplementation, Object[] inputParameters)
    >   at Microsoft.Crm.Sdk.Request.Process()
    >   at Microsoft.Crm.WebServices.CrmService.Execute(Request request)
    >   --- Ende der internen Ausnahmestapelüberwachung ---</faultstring>
    >      <detail />
    >    </soap:Fault>
    >  </soap:Body>
    ></soap:Envelope>
    >
    [2010-04-06 16:51:32.4] Process: w3wp |Thread: 6812 |Category: Platform |User: 564d0467-dfb4-4b6a-8d13-a10826e8081d |Level: Error | CrmSoapExtension.ProcessMessage
     at CrmSoapExtension.ProcessMessage(SoapMessage message)
     at SoapMessage.RunExtensions(SoapExtension[] extensions)
     at SoapServerProtocol.WriteException(Exception e, Stream outputStream)
     at WebServiceHandler.WriteException(Exception e)
     at WebServiceHandler.Invoke()
     at WebServiceHandler.CoreProcessRequest()
     at SyncSessionlessHandler.ProcessRequest(HttpContext context)
     at CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
     at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
     at HttpApplication.ResumeSteps(Exception error)
     at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
     at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
     at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
     at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >CrmSoapExtension detected CrmException:
    System.Web.Services.Protocols.SoapException: Der Server konnte die Anforderung nicht verarbeiten. ---> System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> Microsoft.Crm.CrmArgumentException: -1 is not a valid state code on phonecall. ---> System.ArgumentException: -1 is not a valid state code on phonecall.
    Parametername: stateCode
       --- Ende der internen Ausnahmestapelüberwachung ---
       at Microsoft.Crm.BusinessEntities.StatusCodeValidator.Validate(EntityMetadata entityMetadata, Int32 stateCode, Int32 statusCode)
       at Microsoft.Crm.BusinessEntities.BusinessProcessObject.SetStateStatus(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context)
       at Microsoft.Crm.ObjectModel.PhoneCallService.Microsoft.Crm.Sdk.IStateful.SetStateStatus(BusinessEntityMoniker , Int32 , Int32 , ExecutionContext )
       --- Ende der internen Ausnahmestapelüberwachung ---
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
       at Microsoft.Crm.Sdk.MethodDescription.ExecuteInterface(Object methodImplementation, Object[] inputParameters)
       at Microsoft.Crm.Sdk.Request.Process()
       at Microsoft.Crm.WebServices.CrmService.Execute(Request request)
       --- Ende der internen Ausnahmestapelüberwachung ---

    The StatusCode attribute of the PhoneCall entity shows the correct values:

    StateCode:  1 (Completed)

    StatusCode:  2 (Made)

    I had exported the customizations of the phone call entity and I am not able to see anything wrong.  What else could I check to find out what is causing the issue?

    Thursday, April 8, 2010 3:40 PM

Answers

  • I am afraid that try/catch block may not actually help in your case. Trace log tells everything, it is the ultimate source when it comes to such diagnosis. 

    The key message you get is "-1 is not a valid state code on phonecall". You have actually explicitly set state.PhoneCallState = PhoneCallState.Completed, which is NOT -1. Your code just looks fine. 

    I cannot think of anything that causes this problem except checking your customization. Did you try to publish Phone Call entity's customization? I know Phone Call is a built-in entity, but I am suspecting that the customization of Phone Call has been somehow screwed up for this particular environment. 

    I believe you have done all correct procedures. If your problem cannot be solved, it would probably be better idea to resort to MS support team, they might have better knowledge and experience to deal with all the unexpected behaviors. :)


    Daniel Cai | http://danielcai.blogspot.com
    Friday, April 9, 2010 12:40 PM

All replies

  • Put try/catch  block around your code and catch SoapException and check Detail.InnerText as shown below and it will tell you thr exact problem for this..

     

     catch (SoapException ex)
                            {
                                // Log Entry to Event Viewer
                                string error = "The error is " + ex.Detail.InnerText;

    }

    Thursday, April 8, 2010 3:51 PM
  • I will add the try/catch block and share the results.  Thanks.
    Friday, April 9, 2010 12:22 PM
  • I am afraid that try/catch block may not actually help in your case. Trace log tells everything, it is the ultimate source when it comes to such diagnosis. 

    The key message you get is "-1 is not a valid state code on phonecall". You have actually explicitly set state.PhoneCallState = PhoneCallState.Completed, which is NOT -1. Your code just looks fine. 

    I cannot think of anything that causes this problem except checking your customization. Did you try to publish Phone Call entity's customization? I know Phone Call is a built-in entity, but I am suspecting that the customization of Phone Call has been somehow screwed up for this particular environment. 

    I believe you have done all correct procedures. If your problem cannot be solved, it would probably be better idea to resort to MS support team, they might have better knowledge and experience to deal with all the unexpected behaviors. :)


    Daniel Cai | http://danielcai.blogspot.com
    Friday, April 9, 2010 12:40 PM
  • Thanks for your reply, we will go aheand and open a ticket with Microsoft.

     

    Monday, April 12, 2010 12:57 PM