Search code examples
javascriptasp.netdynamics-crmdynamics-crm-4

Get CRM Popups to Refresh Opening Window


I am loading a Microsoft CRM 4.0 window from an Intranet page using window.open(...).

When the window closes, I need it to programmatically press a button on the page that opened it. I can do this from my own form by getting the button (whose name is passed in the querystring) and executing its click method in JavaScript.

I thought I could try opening my own window with an iframe containing the CRM page as I do with other web-based systems on our Intranet. In the page I can then click the button in the onunload event of the page. However, although this works for most of our systems, with CRM I get two problems.

  1. If I open a window then simply close it I get a CRM error.
  2. If I press the Save and Close button from the CRM window it saves but does not close.

Is there a solution for this?


Solution

  • You could do something like use a basic javascript window.opener call.

    Page 1 opens a CRM window. In the OnSave of that CRM window you call something like this:

    if(window.opener.DoSomeFunction != null)
      {
         window.opener.DoSomeFunction;
      }
    

    Where DoSomeFunction() is a defined javascript function in Page 1. The you could use a PageMethod or a __doPostBack() call. I haven't had a chance to try this inside MS CRM but in theory this approach might work.

    Reference on javascript window.opener:

    http://www.dotnetspider.com/resources/22146-How-call-parent-page-javascript-function-from-popup-window.aspx

    http://www.webreference.com/js/tutorial1/opener.html