Monday, 25 November 2019

Modal Popups in CE - Xrm.Navigation.navigateTo - Dynamics 365 CE

Hi Everyone,

Today I was browsing something and came to know that one of the awaiting feature from many years has been released.

Many times we get the requirement to open something in Modal Popup and we all know that was no way to do that. We have that know OOB.

We just have to use the below code for it. 


var pageInput = { pageType: "webresource", webresourceName: "WebResourceName" };
var navigationOptions = {
    target: 2,
    width: 400,
    height: 300,
    position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
    function success() {
        // Handle dialog closed
    },
    function error() {
        // Handle errors
    }
);

Along with this, we can use NavigateTo to navigate to Dashboards, Views. Use PageInput as below for the same.

  // Navigates to the Entities Default View.
    var pageInput = { pageType: "entitylist", entityName: "contact", viewId:"3a282da1-5d90-e011-95ae-00155d9cfa02" };
    // Navigates to the View that is mentioned in the ViewID.
    var pageInput = { pageType: "entitylist", entityName: "contact", viewId:"3a282da1-5d90-e011-95ae-00155d9cfa02" };
    // Navigages to the specified Dashobard
    var pageInput = { pageType: "dashboard", dashboardId: "45f88f83-0e67-443b-bd05-81d49719f6b1" };


Link from Microsoft Docs


Hope this helps.

--
Happy 365'ing
Gopinath

2 comments:

  1. It's almost great - but how do we close the modal? Been struggling with a clean way to do that, and closing it with the X at the top right isn't a great option. The other default dialogs have buttons - why not here?

    ReplyDelete
    Replies
    1. Very unfortunately as of now, no API support is available for closing the popup. Hope, will get that support soon.

      Delete