Translating error codes to error messages in your ConfigMgr reports.

I was recently working on a set of custom reports on the configuration baseline and configuration item compliance. I noticed some systems failed on a few configuration items so I decided to bring in the ErrorCode info in from the v_CIErrorDetails view.  Unfortunately, as nice as error codes are to have, we don’t know what all of them mean so plain text reason for an error is helpful.  I am going to show you one way to do just that.

First, I am going to run a short SQL query to show some of the error codes I am talking about and what they look like.

I run the following and as you can see -2147467262 doesn’t tell you a lot.

SELECT DISTINCT ResourceID, ErrorCode
FROM           v_CIErrorDetails
ORDER BY ErrorCode

Let’s take that same query and use Report Builder to make a report out of it. I did alter it to just select the TOP(1).

Here is what it looks like in Report Builder

And here is the report

We need to reference SrsResources.dll and use an expression to convert the error code to the text found in the DLL.

Right click in an area outside of the report and go to Report Properties. Go to References and Add a new assembly.  Type in the following:

SrsResources, culture=neutral

And click OK.

Next we need to alter the value of the ErrorCode with an expression to use the assembly and convert the error code. Right click on [ErrorCode} and select Expression.  Replace the currect expression with =SrsResources.Localization.GetErrorMessage(Fields!ErrorCode.Value,”en-US”) but the Field may different for your report.  For me the column is ErrorCode. Click OK and rerun the report.

The report now shows the error message text and not the error code.

I took it a little further and included the error codes in two columns using the following query.

SELECT DISTINCT ResourceID, ErrorCode AS 'Message', ErrorCode
FROM           v_CIErrorDetails
ORDER BY ErrorCode

I use this this expression on the Message field

=SrsResources.Localization.GetErrorMessage(Fields!Message.Value,”en-US”)

And now I have the error code and the error message.

Here are a few links for further information.