locked
CRM pop-up Silverlight application in new browser window issue RRS feed

  • Question

  • Hi Guys,

    I have developed a silverlight application that is launched from a CRM form. The form has a field and in the OnChange event of the field, it calls window.open to open a HTML web resource:

    window.open(serverUrl + "")...

    The HTML web resource contains an iframe that embeds the silverlight control.

    The silverlight control has a "Save Data" button that saves data back to the CRM form. This all works fine on my development PC, however, on other PC, the data are not saved back to CRM.

    I put debugging messages and the Xrm object is null. In the silverlight code, I am accessing the Xrm object by:

     
    HtmlPage.Window.Eval("document.parentWindow.opener.Xrm") as ScriptObject;

    This works on my development PC but doesn't work on other PC, does anyone know why this is happening? Is this a permission or browser settings issue?

    I also tried to run "document.parentWindow.opener.Xrm" in IE developer tool's script window on the other PC while the silverlight control is open, and i can see the DOM object ok??

     

    Regards,

    Jerry

     

    Wednesday, August 28, 2013 4:29 AM

Answers

  • Actually you can get Xrm object from pop up silverlight application, just need to find the correct DOM property. It turned out to be a browser issue:

    It seems i have to get the Xrm object in silverlight directly for it to work in IE9:

    window = HtmlPage.Window.Eval("document.parentWindow.opener.Xrm") as ScriptObject;

    The below code doesn't seem to work in IE9, only works in IE8:

    window = HtmlPage.Window.Eval("document.parentWindow.opener") as ScriptObject;

    xrmObject = window.GetProperty("Xrm") as ScriptObject;

    • Marked as answer by Jerry_Hsi Wednesday, August 28, 2013 10:32 PM
    Wednesday, August 28, 2013 10:31 PM

All replies

  • You will not get Xrm context from a popped out application.  You can expose your webresource on the form through the form editor, then you will get your context.

    Jamie Miley

    Check out RBA Today!

    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!

    Wednesday, August 28, 2013 8:47 PM
    Moderator
  • Actually you can get Xrm object from pop up silverlight application, just need to find the correct DOM property. It turned out to be a browser issue:

    It seems i have to get the Xrm object in silverlight directly for it to work in IE9:

    window = HtmlPage.Window.Eval("document.parentWindow.opener.Xrm") as ScriptObject;

    The below code doesn't seem to work in IE9, only works in IE8:

    window = HtmlPage.Window.Eval("document.parentWindow.opener") as ScriptObject;

    xrmObject = window.GetProperty("Xrm") as ScriptObject;

    • Marked as answer by Jerry_Hsi Wednesday, August 28, 2013 10:32 PM
    Wednesday, August 28, 2013 10:31 PM