locked
CRM 2013: How to opened a view in the same browser window by JavaScript? RRS feed

  • Question

  • In CRM 2011 it is common to open entity records or entity views in new browser windows.

    In CRM 2013, however, the preferred way is to implement the navigation flow within a single browser window.

    As described in http://msdn.microsoft.com/en-us/library/gg328483.aspx, records can be opened with Xrm.Utililty.openEntityForm, and views can be opened by URL, e.g. window.open(viewURL).

    In CRM 2011, Xrm.Utililty.openEntityForm will open an entity record in a new browser window.

    In CRM 2013, Xrm.Utililty.openEntityForm will open an entity record within the same browser window.

    So far, so good.

    How can I open an entity view within the same browser window by JavaScript in CRM 2013?

    Assume a custom HTML web resource being displayed in CRM 2013. I want to open the view from there via a link or a button.

    What I tried in CRM 2013:

    In HTML:

    (1) <a href="viewURL">Open View</a>
    In JavaScript:

    (2) window.open(viewURL, "_self"); (3) window.location = viewURL;

    (4) window.location.href = viewURL;

    (5) window.location.assign(viewURL); (6) window.open(viewURL);



    (1)-(5) do not open the view, but reload the current page.

    (6) opens the view, but in a new browser window.



    Thursday, October 10, 2013 7:32 AM

All replies

  • If you redirect the current page, you're going to lose the navigation bar at the top of the page, effectively preventing the user from navigating anywhere else.

    I guess it depends on your requirement, but I would recommend leaving it as a new window for that reason.


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism


    Thursday, October 10, 2013 8:14 AM
  • Use an iframe and show view in it based on requirement

    Regards Faisal

    Thursday, October 10, 2013 1:39 PM
  • Thanks for your reply!

    So I think it's currently not possible to open the view in the same browser window by JavaScript.

    I hope this feature will be added in CRM2013, e.g. a function Xrm.Utililty.openEntityView. I would expect the view to be displayed in a similar way as it is if you add the view to the sitemap.

    As background information, why we would prefer to open the view in the current window:

    If we open the view in a new browser window, the new window does not have a CRM navigation bar. That's not critical, but not ideal either.

    If we click on an entity in the view, yet another new browser window will pop up to show the entity record. This time the new browser window has a CRM navigation bar, but the browser back button is not visible. This makes any further navigation painful, especially because in our case the opened entity record has child records. So if you continue navigation into the child records, it is difficult to navigate back from a child to its parent.

    Friday, October 11, 2013 11:00 AM
  • Thanks for this interesting approach.

    I will think about that, though I think this functionallity should be built into CRM 2013.

    Further, I wonder what happens to the CRM 2013 menu below the CRM 2013 navigation bar. I guess it will end up with 2 nested menu bars.

    Befor displaying the view within the iframe: [CRM 2013 navigation bar] [CRM 2013 menu for the HTML web resource] The contents of my html web resource goes here. I have no control over the CRM 2013 menu above. After displaying the view within the iframe: [CRM 2013 navigation bar] [CRM 2013 menu for the HTML web resource] [CRM 2013 menu for the view] iframe [ The view

    will be

    displayed here]


    Friday, October 11, 2013 11:12 AM
  • Hi ,

    Can you try Xrm.Utility.openWebResource ? we have used the  Xrm.Utililty.openEntityForm which opens the page in same winowd in mscrm 2013 so, i think Xrm.Utility.openWebResource will work in same way.

    Regards,

    Pragmateam

    Friday, October 11, 2013 12:06 PM
  • Hi Pragmateam, thanks for your reply.

    Xrm.Utility.openWebResource also openes a new browser window / tab.

    Friday, October 11, 2013 12:26 PM
  • Until the CRM Team implement a client sdk function for this the only way is to mimic the OOB CRM navigation behaviour calling raiseNavigationRequest. You need to construct the url correctly including the addition of a sitemappath querystring parameter which ensures the navigation bar updates to the desired location as well. You can see how it is done in practice by view the script QuickViewMenu.js of this solution. http://crm2013quickviewmenu.codeplex.com/

    This is a related MS Connect item https://connect.microsoft.com/dynamicssuggestions/feedback/details/811161/url-addressable-forms-and-views-no-sitemap-shown-for-entitylist-page-type


    MS CRM Bing'd - http://bingsoft.wordpress.com
    Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM 2011 Metadata Browser
    CRM Forum Guidance

    Thursday, January 2, 2014 4:18 PM
    Moderator
  • Thanks, I'll try that.
    Tuesday, January 7, 2014 9:29 AM