Saturday, November 28, 2009

Dynamics CRM Grid customizations - virtually anything possible

(A quick guide on how to dynamically modify the look and content of a Dynamics CRM Grid)


For each project based on the CRM framework which I dealt with, I had plenty of customer requirements around the grids’ look & behaviors. I’m planning to briefly describe hereby some easy ways to implement some of the most requested customizations. Note that all these customizations are not supported nor compliant with MSCRM SDK.

One core functionality you’ll need to address in order to be able to implement my samples below and any others you might need around the grid, is to catch the load event of the grid control. Once you’re able to execute your custom function on grid loading event, you can then browse the document’s DOM and dynamically change the look and behavior of any document element including the grid itself.

The code

A simple way (not the cleanest, I admit) is to define in the /_static/_common/scripts/Globaj.js file an array of functions to be called when the appropriate grid loads:

var grid_onGridLoadDelegates = new Array();
grid_onGridLoadDelegates[New_invoice_line] = new_invoice_line_onBeforeGridLoad;

This code defines the array of functions and then have the function new_invoice_line_onBeforeGridLoad(...) called when a grid displaying entities of type “new_invoice_line” gets loaded.

Then, you’ll need to add several lines in the /_static/_grid/ file, at the end of init() function:

if(grid_onGridLoadDelegates!=null && grid_onGridLoadDelegates[this.element.oname]!=null)
   grid_onGridLoadDelegates[this.element.oname].call(this, window, this.element);

Thus, you can already define like this your custom function to be executed when the grid is loaded:

function new_invoice_line_onBeforeGridLoad(parentWindow, grid)

That’s pretty much it! Here are below some examples based on this approach.


Have particular column for a boolean field replaced by checkboxes when the grid loads.

Implement a “Position” column where the numeric value is replaced by Up/Down arrows having actions which perform server side call for recomputing the line’s position and refresh the grid afterwards.

Have some fields in a column displayed in a variable look, depending on the cell value.

There you go. Let me know if you find this useful.


Sunday, November 22, 2009

It's time to start listing out what we’ve learned for the past years

For the past 4 years I’ve spent most of my time along with my team architecting and delivering small to mid-size solutions based on Microsoft Dynamics CRM 3.0 and 4.0. I had plenty of challenges but also interesting breakthroughs on this road, most of them raised by the clients themselves. Once the license purchased, the clients tended to ask us for more custom business features, going far beyond the original scope of CRM. This is in fact how we ended up delivering real ERPs built on top of the CRM framework rather than CRM solutions. And this was all due to the framework’s flexibility which we ended up exploiting at fullest. We were for sure not the only ones doing this so, at some point along the road, the xRM idea came up...

I will focus in the next articles describing various techniques and ideas we learned in this process.