Leonid Zolotarov
Leonid Zolotarov

Reputation: 191

Xrm.Navigation is undefined

I want to open a modal dialog box, and I write:

var addParams = "entityid=" + Xrm.Page.data.entity.getId() + "&entityName=" + Xrm.Page.data.entity.getEntityName();
var webresourceurl = "/webresources/pdfflr_selectorpage.html?Data=" + encodeURIComponent(addParams);
var parameters = {};
parameters["width"] = parent.document.body.clientWidth * 0.95;
parameters["top"] = '0px';
parameters["left"] = '0px';
parameters["height"] = parent.document.body.clientHeight;
//!!!           
Xrm.Utility.openDialog(webresourceurl, parameters, null, null, null); 

I have to rewrite Xrm.Utility.openDialog to Xrm.Navigation.openWebResource or something like this, but here Xrm.Navigation is undefined.

How can I open a dialog box with Xrm.Navigation?

Upvotes: 4

Views: 1756

Answers (2)

jasonscript
jasonscript

Reputation: 6170

Here's the MSDN Documentation for openWebResource for Dynamics 365 (v9+)

Modal dialogs aren't really supported anymore. You can open a non-modal browser window using Xrm.Navigation.openWebResource

Here's your code transformed:

var data = {};
data["entityid"] = Xrm.Page.data.entity.getId();
data["entityName"] = Xrm.Page.data.entity.getEntityName();

var options = {};
options["width"] = parent.document.body.clientWidth * 0.95;
options["top"] = '0px';
options["left"] = '0px';
options["height"] = parent.document.body.clientHeight;

Xrm.Navigation.openWebResource("pdfflr_selectorpage.html", options, JSON.stringify(data));

Note:

  • Don't need to include "/webresources" in your URL
  • Don't need to include the querystring arguments in your url. There is a data parameter

Upvotes: 0

Henrik H
Henrik H

Reputation: 5787

Xrm.Navigation has been introduced with Dynamics 365 v9. See Some client APIs are deprecated.

For CRM 2011 Xrm.Navigation does not exist. Instead you should use Xrm.Utility.

Upvotes: 1

Related Questions