Reputation: 604
As the title states, I'm looking for a way to tell the difference between an error caused by my code or basic CRM functionality and an error thrown by any custom plugin that may be installed on the clients system.
Something we continuously fall victim to is our clients custom third party plugins that either they created in house or bought from another ISV. They register it on a CRM entity we touch or even on one of our own entities in the most recent case. We try to do something, the plugin tries to do its thing and fails. In the most recent example, the plugin wasn't encoding a ' correctly after we put it into CRM. The plugin throws an error and CRM throws it back to us.
How can I tell that the plugin is the culprit without wasting hours investigating? So far I've only seen one company make it easy to tell by throwing the plugins stack trace as the error message.
EDITS FOR CLARITY:
Upvotes: 5
Views: 2082
Reputation: 2087
Have a look at Detail.TraceText property of exception returned by service. I haven't managed to get full stack trace, but it returned some info indicating where things went wrong:
Mario.CRM.TestOrg.Plugins: Mario.CRM.TestOrg.Plugins.ContactPreUpdate
[5ee31a9e-3558-e211-adeb-00155d014401: Mario.CRM.TestOrg.Plugins.ContactPreUpdate: Update of contact]
Sample code snippet
try
{
//create service proxy and call service
}
catch (Exception ex)
{
Console.WriteLine(((System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)(ex)).Detail.TraceText);
}
Upvotes: 1
Reputation: 18895
This wouldn't be recommended for use in a production environment, but would be extremely beneficial for a testing environment. Whenever a CRUD operation fails using the SDK, you could programmatically disable all plugins, and attempt the same operation. If it succeeds, enable the plugins one at a time until it fails. Then you'd be able to determine which plugin it is that is causing the issue, or whether it is not a plugin at all.
Upvotes: 0
Reputation: 15128
When there is an exception caused by a plugin as this picture:
you can download the log file, inside you can easily find which plugin caused the exception, check for example this log:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: StupidPluginDetail:
// ... other details
[StupidPlugin: StupidPlugin.ExamplePlugin]
[bda9ad85-c4a5-e211-bc00-78e7d162ee67: StupidPlugin.ExamplePlugin: Create of orderclose]
</TraceText>
</OrganizationServiceFault>
Upvotes: 1
Reputation: 15794
The only thing that comes to mind is to enable CRM tracing. The link below should explain how to do this in Microsoft Dynamics CRM.
http://support.microsoft.com/kb/907490
Upvotes: 2