Wednesday, February 24, 2010

View child objects in Iframe

This is a post for my benefit as I can't seem to remember anything. Here's the JavaScript code to display child objects of CRM object in an iframe.

  1. Create Iframe
  2. Modify onload event to populate iframe
  3. Make css changes to iframe to get rid of the white space around the iframe
Here's the code:

  var iframe = crmForm.all.IFRAME_AttorneyFees;
var url = "/UserDefined/areas.aspx?oId="+crmForm.ObjectId
iframe.src = url;

/*clean up css. Makes the iframe look lots better*/
iframe.onreadystatechange = function() {

if(iframe.readyState != 'complete' )
/*Change the background color*/ = "#eef0f6";
/*Remove the left border*/
iframe.contentWindow.document.body.all(0).style.borderLeftStyle = "none";
/*Remove padding*/
iframe.contentWindow.document.body.all(0).all(0).all(0).all(0).style.padding = "0px";
/*Make the cell the full width of the IFRAME*/
iframe.contentWindow.document.body.all(0).style.width = "102%"

The tabset variable in the url variable needs to be the name of the relationship to the child object. You can find this information in the relationships (left hand side of the customize entity form). You have to change the iframe variable to point to the iframe that you are pointing at. You can find this by using the customizations editor->iframe->Name.

No comments:

Post a Comment