faultstring handling

Nov 13, 2012 at 8:32 AM

I am doing the following to create a new entity in CRM:

var e = new XrmServiceToolkit.Soap.BusinessEntity('cvrm_servicebus');
e.attributes["cvrm_requestname"] = requestName; 
var serviceId = XrmServiceToolkit.Soap.Create(e);

And I get the following response ( which is ok and expected )

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="de-DE">Cannot insert duplicate key.</faultstring>
<detail>
<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ErrorCode>-2147220937</ErrorCode>
<ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<a:key>CallStack</a:key>
<a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema"> 
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context) 
at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context) 
at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context) at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)

 However the ServiceToolkit just response with serviceId="" - no error message!

Is that ok?

I would expect an exception saying "Cannot insert duplicate key"!?

Coordinator
Nov 16, 2012 at 7:56 AM

Hi There.

This is definitely an area to improve for future versions.

Thanks very much for the suggestion.

Jaimie