Support to open an Entity form in a new Window in Dynamics CRM 2015 SP1

By | July 24, 2015

Introduction:

Every CRM update comes with a lot of goodies for both the developers and the end users, so Dynamics CRM 2015 SP1 was not different.

One of such feature is opening a record in a new window.

While most of you`ll think, what`s so great in this, we have been doing this since CRM 2011, or maybe even before that.

Well here the difference is, now this is available through CRM API.

Before finding out how to achieve this, let`s run down the memory lane, let`s start with CRM 2011 and understand how this functionality have evolved with every update from CRM 2011 to CRM 2015 SP1.

CRM 2011:

How do we used to open an entity record or simple, a record during CRM 2011 era?

We used to use the JavaScript functionality of window.open() to open up a record.

Syntax:

window.open(URL, name)

URL – server name + URL of the record

name – specifies where to open the window, i.e., on the same page or a new tab or a new window.

CRM 2013:

Now, comes the CRM 2013, complete overhauled design, with added features for developer.

It further simplified the way of opening a record, by providing us a parameterized function. This also ensured that it works across devices.

Syntax:

Xrm.Utility.openEntityForm(name, id, parameters)

name – Name of the entity, whose record we want to open.

id – GUID of the record to be opened, if passed null, it opens an empty record form.

parameters – parameters to be used on the form.

Though it simplified the process of opening a record by eliminating the need to create the URL, still it lacked in one component i.e., giving us the choice whether to open a record on the same page or in a new window.

Remember since CRM 2013, all navigation in CRM is in-place i.e it replaces the current page with the new URL that is requested.

Using the above piece of code to open a record, would very well open the record, but it would open on the same page itself, which was kind of annoying.

What if we want to open a record in a new window then? Well, we have to use the same conventional method i.e., window.open(). As a result this functionality could be achieved but not supported across devices.

CRM 2015 SP1:

Then, came CRM 2015 SP1 update, in this update the openEntityForm method has been enhanced further

It means the method is allowed to take in one more parameter, which on specifying defines where the record would open

Syntax:

Xrm.Utility.openEntityForm(name, id, parameters, options)

options – It`s optional.  It takes in an object in which we have to specify true or false, true means open in a new window and false means to open on the same page. If this parameter is not specified it defaults to false.

How to use this functionality?

First of all create an Object.

var options = {

openInNewWindow : true

};

Note: the property openInNewWindow cannot be replaced by any another name.

Xrm.Utility.openEntityForm(“account”, null, null, options)

The object just takes only one property currently, we cannot specify the height or width of the window to be opened. It by defaults take up the entire screen.

Conclusion:

  • Now, the records can be open in a new window.
  • Currently, we cannot define the size of the window to be opened.

Have a look at our mapping solution for Dynamics CRM, Maplytics which works from with CRM. Email us on crm@inogic.com for a trial or if you would like to see a live demo.