Decode the Error Codes in Dynamics CRM

Microsoft has done a fine job in documenting the web service error codes for all versions of CRM. The web service error codes for CRM 2013 can be found here.

The Error IDs documented on MSDN and CRM SDK are in hexadecimal format. For example, the error code ‘80040516’ translates to a ‘The opportunity cannot be closed’ error message. But when you encounter an error or an exception in your application, the error log displays the error ID in a decimal format. The same exception is displayed with an error code ‘-2147220202’. Searching for this error code on MSDN or CRM SDK may not fetch you the desired results.

What do you do next?

Open the Windows Calculator. Set the view to ‘Programmer’ (ALT + 3). Copy the decimal number and then select the ‘Hex’ option to convert it to a Hexadecimal number. The result displayed would be something like ‘FFFFFFFF80040516’. Strip the ‘FFFFFFFF’ and search SDK for the error code ‘80040516’. This will give you the required information on the error code.