Monday, May 26, 2014

Show your dialog in CRM 2013 modal style

With CRM 2013 we have got one working window without any pop-up windows (lookups, dialogs, e.t.c.). But… only for standard features. What to do in case you wanted to use the same approach with modal windows as CRM does it? I walked through SDK and found following article - http://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource. I tried the code but I have got wrapped window.open method. After some investigations I found how CRM does it:
if (typeof Custom == "undefined") {
    Custom = {
        OpenDialog: function (webresource) {
            var $v_0 = new Mscrm.CrmDialog(Mscrm.CrmUri.create(webresource), window, 370, 370, null);
            $v_0.show();
        },
        __namespace: true
    };
}


and usage is following:

Custom.OpenDialog("/webresources/new_webresource.htm");

Demonstration of how it looks like:



You can use this approach but remember that this code uses undocumented methods so it could be broken with any rollup.