Tuesday, April 5, 2011

CRM 4 – Implementing Dependent Lookups using JScript

Often times you want to restrict the values of a given list based on some selected value of another list. For instance, consider the two lists, Countries and States, where based on the Country selected you only want to show the States of that particular country. There is a nice sample (dependentpicklist) in the CRM 4 SDK demonstrating how you can implement such picklists. In fact, by using the CRM Demonstration Tools you can easily define the dependencies and generate the required Jscript code. However, if we are dealing with Lookup fields instead of Picklists, then having a similar functionality is not that straightforward.

Although CRM 4 doesn’t have out of the box capability to define such lookup fields, there are number of ways you can achieve this including 3rd party CRM modifications such as Stunnware Filtered Lookup. How ever in this post we will see a really simple way to achieve this by using only JScript and the built-in search feature of the lookup view.

VS 2010 Code Analysis – Code Metrics

One of the most important aspects of software is it’s quality. In fact, improving the quality is an integral part of any process improvement initiative. However, as with many other things, quality is better understood and effective if we can express that in terms of quantitative metrics as appose to qualitative measures. If you have followed even a basic computer science program, you may have learnt an array of such metrics. How ever, accurately calculating these metrics was not possible without using specially designed tools. Fortunately, Visual Studio had this capability for some time, but with Visual Studio 2010, the metrics calculation has greatly improved. For instance, the VS2010 even consider complex code blocks such as try..catch and switch when calculating the code metrics.

Calculating Code Metrics

Calculating code metrics in VS2010 is pretty straightforward. If you want to calculate code metrics for the entire solution, you may right-click the solution and select “Calculate Code Metrics” from the context menu. If you just need to calculate metrics for a given project, just right-click that project and select Calculate Code Metrics.

Figure: Solution Context Menu