Sometimes I want to show related entities in iFrames on the forms rather than via the LHS navigator. The technique shown below allows you to do this quickly and easily and allows you to have a number of related entities showing this way on the same page.
For this example I will show a related entity called new_city in an iFrame called Cities. In the IFrame properties it is important that restricting scripting is UNticked and that the ID is passed. The IFrame is therefore referenced as crmForm.all.IFRAME_Cities (ignore the old entiy names in the pics below).
I set the contents of the IFrame in the onLoad event using the following line of code and the function shown below
The function that I use to set the contents of the IFrame is included as part of the onLoad for the page (make sure it is loaded before the line above is called)
//----------------------------------------------------------------------------------------------
function getFrameSource( tabSet ) {
//----------------------------------------------------------------------------------------------
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
//this two lines are optional and used to hide th link on the LHS navigation
var navItem = window.document.getElementById( 'nav_'+ tabSet );
navItem.style.display = 'none';
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
} else {
return "about:blank";
}
};
//Line to in set IFrame contents
crmForm.all.IFRAME_Cities.src = getFrameSource('new_new_state_new_city');