Monday, September 22, 2008

CRM Master Detail Page – Part 1

This is a nice and simple solution you can use to enable inline navigation between CRM entities OR in other word a master detail display. This is also considered an excellent alternative to not having the ability to edit the crm grid since the user doesn’t have to leave the current entity window which completely eliminates the open - close page problem and the entity fields are always available for editing.

The idea behind the solution is to create an iframe using customization, set the iframe src attribute to any view you like to show and use this code in the onload event. The only thing the code does is override the iframe function which means that when the user double clicks on a record, instead of the opening a new window, the current window url is replaced with to the selected record url.

function OnCrmPageLoad()
/* Reference the IFrame */
var IFRAME_test = document.all.IFRAME_test;
/* Assign the IFrame URL */
IFRAME_test.src = DecideOnTheIFrameGridUrl();
/* Override the onreadystatechange Event */
IFRAME_test.onreadystatechange = function ()
/* if the IFrame is ready == 'complete' */
if( IFRAME_test.readyState != 'complete' )
/* Remove the IFrame border since the grid already has one */ = "0px";

/* Remove the IFrame padding and scroll */
var IframeWindo = IFRAME_test.contentWindow;
IframeWindo.document.body.scroll = "no"; = "0px";

This is what you really after!
Override the IFrame function
So the selected record url replaces the current one.
*/ = function( url )
location.href = url;
return false;


function DecideOnTheIFrameGridUrl()
//This will show the entity default view
return "/" + ORG_UNIQUE_NAME + "/_root/homepage.aspx?etc=" + crmForm.ObjectTypeCode;