Donnerstag, 1. März 2012

Dynamics CRM 4.0 - Error Showing Related Money field in a Dynamics CRM 4.0 View

Dynamics CRM 4.0 - Error Showing Related Money field in a Dynamics CRM 4.0 View


One of our clients recently came across an error when navigating to a customized view in Microsoft Dynamics CRM 4.0. Basically, a CRM user was trying to add a money field of a related entity as a column of the view. After publishing the changes to the entity, the user navigated to the view in CRM only to receive the generic An Error has Occurred dialog.
Error Showing Related Money field in a Dynamics CRM 4.0 View
This type of error message doesn’t give us much information at all, but there are some debugging techniques we can use to track down the error. Firstly, we need to see which field on the view is causing the error. We have two fields from related entity on the view – one money field, and one lookup field. We can try to remove the lookup field and publish the view to see if this prevents the error from being displayed. As expected, the error no longer shows up so we can conclude that the money field is causing the issue.
Next, we can check the Event Viewer on the CRM server assuming we have administrator privileges and we are using an on-premise implementation. We want to choose the Windows Logs -> Application to identify any errors with CRM.
Error Showing Related Money field in a Dynamics CRM 4.0 View
We can see that the Event Viewer is definitely picking up an error of some sort, but there’s not a lot of information. It appears that a plugin registered on the Retrieve Multiple message has failed so for starters we can check any plugins we have developed registered on this message. Unfortunately for us, there were no plugins registered on this message with the affected entity, but we decided to disable all plugins just in case. However, this made no difference as the error was still being displayed but we can rule out that a plugin is causing the error.
Money fields in CRM are stored in multiple columns. We have the money field itself, as well as a value in the base currency. It could be possible that the two fields to not match, thus an error is being thrown by the CRM platform when trying to retrieve them. We can run a simple SQL script inside SQL Server Management Studio to see if this is the case.
Error Showing Related Money field in a Dynamics CRM 4.0 View
The results show that the money field and its corresponding base value are identical, so we can also rule this out as a possible cause for the error. Finally, we can turn on tracing on the CRM server to give us information on all actions being performed by the CRM platform. To turn on tracing, you need to run the Microsoft CRM Diagnostics tool for CRM 4.0.
Error Showing Related Money field in a Dynamics CRM 4.0 View
Open up the tracing file in Notepad and do a search for the schema name of the problematic field. In this case, we will search for “mag_amount1”. The trace file gives us the exact cause of the error in CRM and tells us that the “transactioncurrencyid” is missing from the view.
The reason we need to add the currency field to the view is because the entity we are working with doesn’t have a currency field since it does not have any money field defined for the entity. When we add the money field from a related entity to the view and try to display the results, CRM does not have any currency information for the field, so fails to convert the field to the right currency. For this reason, we must also include the currency field from the related entity for the view to be displayed correctly.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Free Samples By Mail