All the world's a game, or it will be soon. That's the position taken by Jesse Schell in his blog Gamepocalypse Now. Games appeal to people at an emotional level - they're fun and sometimes addictive. Wouldn't you like your CRM system to be fun and addictive? This sample code shows you how to add a social game on top of Microsoft Dynamics CRM 2011 - an Achievements system much like Xbox Live or the badges on Foursquare.
The code is included in a Visual Studio project for you to peruse. However, I recommend you simply import Achievements_1_0_0_0.zip into your CRM development organization. It's an unmanaged solution so that you can read, edit, or delete any code you want. See Achievements - Concept and Install Guide.docx for details.
Achievements and Badges are entities added to the CRM system. Achievements represent attaining some kind of status, completing some task, or participating in some project. Badges track which users have earned which achievements. The image below shows a rough diagram of the data model (SystemUser is 1:N with Badge; Badge is N:1 with Achievement) and the code/HTML files which support each entity.
I gave a video talk about this solution a few months ago. It was originally hosted here: http://www.xrmvirtual.com/events/xbox_xrm but has since been taken down. A mirror is available at https://github.com/vtbassmatt/XrmAchievementsGame.