Dynamics CRM 2011 · Javascript

CRM 2011: Open Entity Form with Xrm.Utility

I just learned something interesting this morning from my colleague Iain.

Previously when I have to open a record in a new page, I have to construct the correct url, inject the right guid and then use window.open to open the form.

With Xrm.Utility, all I need to do is:

//Open a new account record
Xrm.Utility.openEntityForm("account"); 

//Open an existing account record
Xrm.Utility.openEntityForm("account","A85C0252-DF8B-E111-997C-00155D8A8410"); 

//Open a new account record with a specific form and setting default values
var parameters = {};
parameters["formid"] = "b053a39a-041a-4356-acef-ddf00182762b";
parameters["name"] = "Test";
parameters["telephone1"] = "(425) 555-1234";
Xrm.Utility.openEntityForm("account", null, parameters);

//Open a new contact record, move it to the top left corner of the screen, and set the size of the window
var newWindow = Xrm.Utility.openEntityForm("contact");
newWindow.moveTo(0,0);
newWindow.resizeTo(800,600);

Read more on MSDN here.

Cheers,
Sy

Advertisements

One thought on “CRM 2011: Open Entity Form with Xrm.Utility

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s