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?

Answers:

Answer

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

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.