2013 Microsoft Dynamics CRM - Change forms using JS

让人想犯罪 __ 提交于 2019-12-13 03:48:16

问题


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. 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?


回答1:


I've done similar things before. Answer for you is to use Xrm.Utility.openEntityForm method. Description how to use it you can find here - https://msdn.microsoft.com/en-us/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. Here is code you should use to make openEntityForm to work properly:

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



回答2:


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


来源:https://stackoverflow.com/questions/46833707/2013-microsoft-dynamics-crm-change-forms-using-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!