Home > MS CRM 4.0 > Creating Master Detail views

Creating Master Detail views


////////////////// Master Detail View ///////////////////////////

///// SETUP ////////

var IframeMaster = "IFRAME_orders"; //IFrame name for the master view

var

IframeDetail = "IFRAME_orderdetails"; //IFrame name for the details view

var

MasterUrl = "../../sfa/accts/areas.aspx"; //It has to be the full URL from the root element but using relative urls, thus the use of "..". For a custom entity "../UserDefined/areas.aspx";

var

MasterTabSet = "areaOrders"; //Area or relationship name for the master

var

DetailUrl = "../../sfa/invoice/areas.aspx"; //Same conditions as the master Url

var

DetailTabSet = "order_details"; //Area or relationship name for the deatil

////////////////////

var

LastSelection = null;

function

Nsi_Initialise() {

//Init Master Iframe

document.frames(IframeMaster).frameElement.attachEvent(

"onreadystatechange", Nsi_OnReadyStateChange);

document.frames(IframeMaster).frameElement.src = Nsi_GetFrameSource(MasterUrl, MasterTabSet, crmForm.ObjectId, crmForm.ObjectTypeCode, crmFormSubmit.crmFormSubmitSecurity.value);

}

function

Nsi_OnChangeMaster() {

if (document.frames(IframeMaster).document.all[‘crmGrid’].InnerGrid.SelectedRecords.length > 0) {

crmForm.all[IframeDetail].style.display =

"block";

var masterId = document.frames(IframeMaster).document.all[‘crmGrid’].InnerGrid.SelectedRecords[0][0];

var masterTypeCode = document.frames(IframeMaster).document.all[‘crmGrid’].InnerGrid.SelectedRecords[0][1]; //Update detail view

if (masterId != LastSelection) {

document.frames(IframeDetail).frameElement.src = Nsi_GetFrameSource(DetailUrl, DetailTabSet, masterId, masterTypeCode, crmFormSubmit.crmFormSubmitSecurity.value);

LastSelection = masterId;

}

}

else {

crmForm.all[IframeDetail].style.display =

"none";

}

}

function

Nsi_OnReadyStateChange() {

if (document.frames(IframeMaster).frameElement.readyState == ‘complete’) {

document.frames(IframeMaster).document.all.crmGrid.attachEvent(

"onselectionchange", Nsi_OnChangeMaster);

Nsi_OnChangeMaster();

}

}

function

Nsi_GetFrameSource(url, tabSet, oId, oType, security) {

var result = url + "?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;

return result;

}

if

(crmForm.FormType != 1)

Nsi_Initialise();

Advertisements
Categories: MS CRM 4.0
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: