For those of you trying to access a parent form’s Xrm.Page object in CRM 2011 you can use the following syntax.
From an IFrame HTML page
document.parentWindow.parent.Xrm.Page
From a new window/dialog
window.top.opener.parent.Xrm.Page
An example of a new window being used is when you are viewing the Account Form and then choose to create a new Contact from the left hand navigation pane and then within the Contact Form you need to access the Account Form (parent).
Potential CRM 4 syntax to be replaced is as follows
window.opener.parent.document.crmForm window.opener.document.crmForm window.opener.parent.crmForm
If you have downloaded the CRM 4 to CRM 2011 JavaScript Converter Tool before December 2010 then you can add the following code snippets to the TOP of the ConversionList.xml file straight after the <snippets> node, alternatively just download the tool again.
<snippet> <crm4>window.opener.parent.document.|_|;</crm4> <crm5>window.top.opener.parent.|_|;</crm5> </snippet> <snippet> <crm4>window.opener.document.|_|;</crm4> <crm5>window.top.opener.parent.|_|;</crm5> </snippet> <snippet> <crm4>window.opener.parent.|_|;</crm4> <crm5>window.top.opener.parent.|_|;</crm5> </snippet>
Both Mitch Milam MVP and I searched high and low for this solution as the Xrm.Page object is not in the DOM at that same location as the CRM 4 crmForm object. Please let us know if you experience any problems with accessing parent forms and we will try and help you.
Also if you liked my CRM 4 to CRM 2011 JavaScript Converter Tool then you might like to take a look at Mitch Milam’s CRM Migration Assistant also for converting scripts.
From IE Developer Tools
Also, Paul Way has shown that you can access the Xrm.Page object from the Developer Tools console window using the following code.
frames[0].Xrm.Page