Here’s how to reload the parent window with Dynamics CRM 2011:
A word of explanation:
- window.top.opener is the opener window
- window.top.opener.top is used to make sure the whole page is refreshed and not an iframe
- window.top.opener.top.document.location.reload() to reload
Pay attention, when opening the new window, to use a relative URL, or to be sure that the server name that you get when calling:
is the same as the one you are currently connected to. By that, I mean that it may happen that you connect to CRM server using localhost, the IP address or the fully qualified domain name, while getServerUrl will give you the base server name. As explained in the SDK:
The URL returned is the standard URL used to access the application. If you access the server locally using http://localhost or use an IP address instead of the actual name of the server, this will not be reflected in the value returned by this function. This means that if you are making web service calls or accessing web resources, the browser will apply security settings that apply to requests that cross domains.
So for example, using window.open, and trying to reach the opener window from the child window, you will get an “access is denied” error. And you will see strange behavior when looking at the Xrm.Page object, with Xrm.Page.ui and Xrm.Page.data being null if I am not mistaken.
By the way, from Update Rollup 8, the new way to open a popup window is to use this function:
Xrm.Utility.openEntityForm (or openWebResource)