CRM 2011 How to: Set IFrame control content dynamically
CRM 2011 features the Sub Grid which allows displaying related records grid in the form of the parent entity using only customization tools. For example, displaying all open Opportunities in the form of the parent customer.
This is a great feature which was missing in version 4.0 and required some scripting. Yet, some entities are not supported by this feature. For example, the Audit entity (which is not available in Advanced Find as well. Why???).
To solve this problem, you can use the following function in the parent entity form OnLoad event, while setting the required parameters. Note that you can send the entity from id as an optional parameter in case the Sub Grid is relevant to a specific entity form.
In this example, I used the following parameters to call the function in the Account OnLoad event, assuming the Account form has an Iframe control named IFRAME_audit.
"IFRAME_audit", 1, "areaAudit", "Audit History",""
//iframeObjId – iframe control schema name
//objectType – container entity code
//areaName – related entity area name
//formId – entity form id (optional)
function SetIframeContent(iframeObjId, objectType, areaName, iframeTitle, formId)
//Get iframe control
var iframeObject = Xrm.Page.getControl(iframeObjId);
if (iframeObject != null)
var strURL = "areas.aspx?formid=" + formId + "&navItemName=" + iframeTitle + "&oId=" + Xrm.Page.data.entity.getId() + "&oType=" + objectType + "&pagemode=iframe&security=852023&tabSet=" + areaName;
//Set iframe URL
By default, when using this solution, the form ribbon lose its context sensitivity. In order to work around this, map the following function to the iframe OnReadyStateComplete event (in the iframe events tab). It’s an ugly solution, but it works:
Finally, this function is not documented in the SDK and therefore not supported.