Showing posts with label Xrm.Utility.openEntityForm.Xrm in MS CRM. Show all posts
Showing posts with label Xrm.Utility.openEntityForm.Xrm in MS CRM. Show all posts

Tuesday, October 28, 2014

Xrm.Utility.openEntityForm for Dynamics CRM 2013/2011

Open a new account record using JavaScript
Xrm.Utility.openEntityForm(“account”);

Open an existing account record JavaScript
Xrm.Utility.openEntityForm(“account”,”A85C0252-DF8B-E111-997C-00155D8A8410″);

Open a new account record with a specific form and setting default values JavaScript
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 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
Xrm.Utility.openEntityForm(“appointment”,null,parameters);

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