When I say slightly improved, let me emphasize the word slightly... ...
The code that displays related entities in an IFRAME has been around for quite a while. For the sake of not reinventing the wheel, here it is: http://robscrm.blogspot.com/2007/11/showing-related-entities-in-iframe.html.
When you render the IFRAME it doesn't look as professional as a normal CRM view. The borders have a lot of white-space and the IFRAME just looks out of place. A while back Microsoft sent me some code that does related entities for three entities at a time in a tabbed IFRAME. It is essentially the same things as the basic related entities IFRAME times 3 entities. Good stuff!
So, when i looked at the IFRAME I noticed that the formatting problems didn't exist. After one of our business analysts asked if I could clean up the styling on the related entity IFRAME, I decided to leverage the code.
Before Fix
After Fix

So, here is the code. Enjoy.
-Andrew
function GetFrameSource(tabSet) {
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
}
else {
return "about:blank";
}
}
// Waits for the content window of the IFrame to be ready
function FixStylingInFrameSource(iframeID) {
// Check the content window's ready state
if (document.getElementById(iframeID).contentWindow.document.readyState
!= "complete") {
// Re-run this function in 10 ticks
window.setTimeout(function() { FixStylingInFrameSource(iframeID) }, 10);
}
// Content window is ready
else {
// Change the background color
document.getElementById(iframeID).contentWindow.document.body.style.backgroundColor = "#eef0f6";
// Remove the left border
document.getElementById(iframeID).contentWindow.document.body.all(0).style.borderLeftStyle = "none";
// Remove padding
document.getElementById(iframeID).contentWindow.document.body.all(0).all(0).all(0).all(0).style.padding = "0px";
// Make the cell the full width of the IFRAME
document.getElementById(iframeID).contentWindow.document.body.all(0).style.width = "102%"
// Show the IFrame
document.getElementById(iframeID).style.display = "block";
}
}
if(crmForm.FormType != 1)
{
crmForm.all.IFRAME_contacts.src = GetFrameSource("areaContacts");
FixStylingInFrameSource('IFRAME_contacts');
}
Posted
01-14-2010 9:47 PM
by
Andrew Zimmer