, , ,

Hello Everyone,

Recently I had a requirement for one of the client where I was suppose to Create Lead on click of a Ribbon Button present on the Custom Entity.

During Lead Creation the values were also suppose to flow from the Custom Entity to Newly created Lead. And after the Creation of the Lead, the Custom Entity was suppose to get Deactivated Instantly.

What we would think of as a normal process to open a new Entity record; construct a correct URL and use window.open to open the form. Its very well explained here, and well documented on MSDN.

But after some reading I also came across a new function that came along with the Update Rollup 8 as a replacement for windows.open

Xrm.Utility provides a better developer experience than the process of manipulating the URL passed to the window.open method. One of the benefit of using this function is that Users are not prompted to log in again under certain circumstances.

Few of the Examples are :

Open a new Lead record:


Open an existing Lead record:


Open a new Lead record with a specific form and setting default values:

var parameters = {};
parameters[“formid”] = “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”;
parameters[“subject”] = “Test”;
parameters[“mobilephone”] = “9876543210”;
Xrm.Utility.openEntityForm(“lead”, null, parameters);

Open a new Lead record, move it to the top left corner of the screen, and set the size of the window:

var newWindow = Xrm.Utility.openEntityForm(“lead”);

Its has been explained in detail on MSDN.

Hence, I first created a WebResource with the following JScript; to create a new Lead with the values flowing from custom Entity to the newly created Lead.

function Lead( ) {
var parameters = {};
parameters["subject"] = Xrm.Page.getAttribute("new_name").getValue();
parameters["emailaddress1"] = Xrm.Page.getAttribute("emailaddress").getValue();
parameters["mobilephone"] = Xrm.Page.getAttribute("new_mobilephone").getValue();
Xrm.Utility.openEntityForm("lead", null, parameters);

Then with the help of Visual Ribbon Editor(which I personally use often for editing ribbons), created a Ribbon Button and called the Function along with its WebResource.

The Next part of Deactivating the current Custom Entity and Refreshing the Parent Grid view on Home page will be discussed in my latter blog.

Thanks !!!