{New Scripting reference}Variants of Xrm.Utility.openEntityForm for Dynamics CRM 2013

Xrm.Utility.openEntityForm was introduced in new scripting reference from Microsoft.

It has few variants and I only found few blogs for a complete reference for it. Adding my findings here (Reference from MSDN site):

Open a new account record



Open an existing account record



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);

Now some pointers on few things it can not do:

· Open a new record with setting form values for regardingobjectid will not work. So, in that case, the Workaround? Here we go:

Open Form Script

//set the parameters to pass to the new form
var parameters = {};
var Regarding = Xrm.Page.getAttribute(“regardingobjectid”).getValue();
parameters[“parameter_regardingid”] = Regarding[0].id;
parameters[“parameter_regardingname”] = Regarding[0].name;
parameters[“parameter_regardingtype”] = Regarding[0].entityType;
//Open the new form

onLoad Script for new form which needs to be opened:

// Get the Value of the Regarding through the Customer Parameters
var param=Xrm.Page.context.getQueryStringParameters();
var regardingId=param[“parameter_regardingid”];
var regardingName=param[“parameter_regardingname”];
var regardingType=param[“parameter_regardingtype”];
//Populate the Regarding if there is one
if (regardingId != undefined)
  {Xrm.Page.getAttribute(“regardingobjectid”).setValue([{id:regardingId, name:regardingName, entityType:regardingType}]);}  

· In some cases, it might not work for Lookup attributes on custom entities, there is no official documentation, but an approach similar to one mentioned above will work.

Hope it helps!


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 )

Facebook photo

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

Connecting to %s