Our team has been working on a large Dynamics CRM upgrade over the past few months from version 4.0 to 2011. I haven't had a lot of exposure to the project over this time, but had the chance to perform some bug fixes and work on some customizations in the system. I encountered an interesting issue when creating a Course record from an Event where the Course form would crash and give me the dreaded message - "An error has occurred".
This doesn't provide us with much information as to what's going wrong so I checked the Event Viewer which didn't show any errors or warnings, but did contain an entry categorised as "Information". The detail of the event shows the following error:
"The given key was not present in the dictionary"
I have seen this type of error when developing plugins for CRM, however this was not a plugin issue. The weird thing about this issue was that I could create a Course from some Events but not others, and I could also create stand-alone Courses. This led me to believe that this could be an issue with mappings.
After checking the 1:N relationship definition between Event and Course, I noticed a mapping between the statuscode fields. It turns out that the statuscode for Event contains more options than the statuscode for Courses. This means that there isn't always a perfect mapping between the two entities.
I deleted the mapping between the two entities, published customizations and attempted to create a Course again. This time it worked without any issues!