views:

1267

answers:

2

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?

A: 

Aren't the errors caused by cross-site-scripting prevention? Unless the intranet app and CRM reside on the same server, sending data back and forth between them is annoyingly difficult.

Sorry if I don't exactly understand what you want to accomplish, but I can't entirely visualize your description. Maybe a simple sketch/drawing will help?

I'm working with Dynamics CRM myself at the moment and am happy to help, since we've ran into all kinds of issues with it and had to invent numerous workarounds. Happy to share.

+1  A: 

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

brendan