Dynamics CRM JS打开创建记录页面(Dynamics CRM JS opens the create record page)

// 以下示例是OP V9.0版本

//是客户窗体页面打开商机创建记录页面,需要将客户信息带入到商机页面。customerid为商机实体lookup客户字段。

 var parameters = {};

  // 如果传递的变量是 lookup 类型的字段,需要分别存储 id 和 name、type。

  parameters[“customerid”] = Xrm.Page.data.entity.getId().replace(“{“, “”).replace(“}”, “”);

  parameters[“customeridname”] = Xrm.Page.getAttribute(“name”).getValue();

  parameters[“customeridtype”] = Xrm.Page.data.entity.getEntityName();

  // 设置文本字段

   parameters[“quotenumber”] = “opp-” + Date.parse(new Date());

  //设置为true则会在新窗口打开,false是在当前标签打开

  var options = { openInNewWindow: false };

  //打开新建 entity record 窗口,这里的entityName指相对应需要打开的 entity 的 name

  Xrm.Utility.openEntityForm(“opportunity”, null, parameters, options); 

————————

//The following example is op v9.0

//The customer form page opens the opportunity creation record page, and the customer information needs to be brought into the opportunity page. CustomerID is the opportunity entity lookup customer field.

 var parameters = {};

// If the passed variable is a lookup type field, you need to store ID, name and type respectively.

  parameters[“customerid”] = Xrm.Page.data.entity.getId().replace(“{“, “”).replace(“}”, “”);

  parameters[“customeridname”] = Xrm.Page.getAttribute(“name”).getValue();

  parameters[“customeridtype”] = Xrm.Page.data.entity.getEntityName();

// Set text field

   parameters[“quotenumber”] = “opp-” + Date.parse(new Date());

// Set to true to open in a new window, and false to open in the current tab

  var options = { openInNewWindow: false };

// Open the new entity record window. The entityname here refers to the name of the corresponding entity to be opened

  Xrm.Utility.openEntityForm(“opportunity”, null, parameters, options);