简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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