Thursday 12 June 2008

Decrypting the Soap Exceptions thrown by CRM 4.0

I know this has been covered a million times before, but for those new to CRM, here's how to get around the unhelpful soap exception "Server was unable to process request".

Make sure you catch the soap exception, not just the standard System.Exception, this will open up an object called Details that has a property called InnerText. This will give you some more information surrounding the actual cause of the exception. But make sure you catch the System.Exception too, just in case.

So:

try
{
...
}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw new InvalidPluginExecutionException(ex.Message+", "+ex.Detail.InnerText);
}
catch (System.Exception ex)
{
throw new InvalidPluginExecutionException(ex.Message);
}

Have fun,
Bossie

2 comments:

Oz said...

Dear Paul,

I am a bit new to CRM customization. I have an issue which is the cause to a lot of hiccups in my customisation. In the account section when I select the "parent account" lookup it always selects the "Account name", instead my client wants account number to be appearing in the lookup. Is it possible to change the attribute? Because it always pulls the primary attribute. I guess I have to write a onload script to change the attribute. Can you help me with it?

Anonymous said...
This comment has been removed by a blog administrator.