Dynamics 365 Model Driven App new navigateTo API

Jared Johnson, 12 November 2019

In early October a new method was added to the Xrm.Navigation client api documentation, navigateTo.

While we already had the openForm method to open a form with Javascript, we had no way of opening a view the same way. This new method now allows us to do that but is only supported in the Unified Interface.

For example, you can open the default view for contacts using the code below:

Xrm.Navigation.navigateTo({pageType:"entitylist", entityName:"contact"}) 

Or open a specific view by including the viewId

Xrm.Navigation.navigateTo({pageType:"entitylist", entityName:"contact", viewId:"00000000-0000-0000-0000-000000000000"}) 

While it is currently not mentioned in the documentation, it is also possible to open dashboards which also do not have another method of navigating to them. For dashboards the pageType needs to be set to ‘dashboard’, and you can include the dashboardId property to open a specific dashboard, otherwise it will open the default dashboard.

Xrm.Navigation.navigateTo({pageType:"dashboard", dashboardId:"00000000-0000-0000-0000-000000000000"}) 

It is also possible to open web resources using this method using ‘webresource’ as the pageType and adding webresourceName.

Xrm.Navigation.navigateTo({pageType:"webresource", webresourceName:"mag_/html/webresourcetest.html"})

While you could just use the openWebResource method, navigateTo will open the webresource without opening a new window similar to if web resources are used in the site map, while openInNewWindow currently does nothing in the openWebResource method and will always open a new window.