简体   繁体   English

2013 Microsoft Dynamics CRM-使用JS更改表单

[英]2013 Microsoft Dynamics CRM - Change forms using JS

I've got a custom entity that has multiple forms. 我有一个具有多种形式的自定义实体。

To create a new form, this is done via a sub-grid. 要创建新表单,可通过子网格完成。 The user just clicks the plus button on the subgrid. 用户只需单击子网格上的加号按钮。 This populates certain fields on the form. 这将填充表单上的某些字段。 I want to be able to change to a specific form, and pass the data that is populated into the fields across. 我希望能够更改为特定格式,并将填充的数据传递到各个字段中。

Currently, I've used the Xrm.Page.ui.formSelector library to switch between forms based on when the entity is in create mode. 当前,我已经使用Xrm.Page.ui.formSelector库基于实体处于创建模式的时间在表单之间进行切换。 I use this to switch between the forms: 我用它来切换表格:

   Xrm.Page.ui.formSelector.items.get("48faf3de-5b78-4ce9-a5f7-a01222e4e857").navigate()

How do I pass the data that is populated when the form is changed? 更改表单时如何传递填充的数据?

I've done similar things before. 我以前做过类似的事情。 Answer for you is to use Xrm.Utility.openEntityForm method. 您的答案是使用Xrm.Utility.openEntityForm方法。 Description how to use it you can find here - https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenEntityForm 描述如何使用它,您可以在这里找到-https: //msdn.microsoft.com/zh-cn/library/jj602956.aspx#BKMK_OpenEntityForm

If you want to add fields to be populated you will have to use approach similar to url addressable forms . 如果要添加要填充的字段,则必须使用类似于url可寻址表格的方法 Here is code you should use to make openEntityForm to work properly: 这是使openEntityForm正常工作时应使用的代码:

var parameters= {}; 
parameters["formid"] = "guid"; 
parameters["lookupName"] = "guid"; 
parameters["lookupNamename"] = "name"; 
//parameters["lookupNametype"] = "entityName";//populate this ONLY in case when lookup type is 'owner' or 'customer'
Xrm.Utility.openEntityForm("entityName", null, parameters, null);

My recommendation is to save the record, so no need to worry about passing the prepopulated field values. 我的建议是保存记录,因此无需担心传递预填充的字段值。 Then navigate to the required form. 然后导航到所需表格。

Xrm.Page.data.entity.save();
.
.
.
Xrm.Page.ui.formSelector.items.get(formId).navigate();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM