Accessing the Parent Form Xrm.Page in CRM 2011

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

CRM 4 to CRM 2011 JavaScript Converter Tool

This project is superceded by the new application Dynamics XRM Tools which includes improved features http://dynamicsxrmtools.codeplex.com/

Here I have a CRM 4 to CRM 2011 Javascript Converter tool that helps convert scripts to the latest CRM 2011 Form scripting model. The converter uses an xml file that contains CRM4 and CRM5 nodes which allow the converter to find/replace specific instances of text.

I created this as an aid to help me during upgrades from CRM 4 to CRM 2011, so if you would like to test it against your CRM 2011 javascript web resources after you upgrade from CRM 4 then let me know how it goes.

You can find the tool on codeplex here.

CRM 4 to CRM 2011 JavaScript Converter Tool

CRM 4 to CRM 2011 JavaScript Converter Tool

Has this Tool saved you time…

If you have benefited from downloading and using this tool, please feel free to donate an amount of your choice. Thankyou

GBP – Donate via PayPal - GBP>

USD – Donate via PayPal - USD>

Euro – Donate via PayPal - Euro>