1
votes

We have a CRM 2011 solution with several custom ASP.NET MVC-based views and forms that are displayed in iframes on entities in CRM. Currently we're doing some analysis on upgrading to CRM 2013, and we've run into a problem with opening entity windows.

We have mostly used window.open throughout the solution, both in JavaScripts on the CRM side of things, and in the custom ASP.NET MVC application. The URL passed to window.open is in the following format:

http://crm.contoso.com/Contoso-Org/main.aspx?etn=opportunity&pagetype=entityrecord&id={...}

The problem is that this seems to remember the context when it's opened in CRM 2013, so it just reopens the entity it was opened from. We solved this on the CRM end by using Xrm.Utility.openEntityForm instead, but it doesn't seem as if that is possible for the custom application, as we don't have access to the Xrm library from inside the iframe. The URL is correct, and if it's copy pasted into a new tab, it correctly loads the desired entity. When loaded with window.open though, it just reopens the same entity.

Some suggestions have pointed to appending a histKey parameter consisting of a randomly generated number to the opened URL. However, this does not work consistently - sometimes it opens the correct entity, sometimes it just reopens the current entity - nor is it officially documented anywhere.

Has anyone come across a solution to this?

2
I'm a little confused by your question. It sounds like you've fixed the issue loading from within CRM, but from your MVC, it isn't working? If you're opening up a new window from an external app, what is the "same entity"?Daryl
Let's say I'm viewing an Opportunity record. There, we have an iframe displaying our MVC application. The MVC application contains an <a> which is supposed to open the Account that the Opportunity is related to. The etn parameter is set to account and the GUID points to the Account entity. However, when clicking the URL, it just opens the same Opportunity it was opened from instead. So it somehow "remembers" the context it came from, even if it's opened in a new tab. CRM seems to append a hash code which is identical, so there's possibly some internal state at play.Martin Wedvich

2 Answers

2
votes

I had a similiar issue with opening CRM 2013 URLs and was able to fix it by adding two query strings histKey (which takes a random number as value) and newWindow to the URL, as follows:

  • "histKey=" + Math.floor(Math.random() * 10000)
  • "newWindow=true"

Hope this helps.

0
votes

Try the following:

  1. Change the A tag target to _blank

  2. Give the window a new name i.e. open(url, new_name, features)

  3. A workaround might be to create an IFRAME inside your MVC app and pass the URL back to a CRM form which eventually open the account form.

  4. Use Wscript.Shell ActiveX to open a new IE process (last resort).

  5. This link might help http://steveliles.github.io/cross_domain_inter_frame_communication_in_javascript.html

HTH

Dynamics CRM - Thinking outside the BOX