Update Entity Form JS Library Without Removing Event Handlers - Quick Workaround

Requirement

Let’s say we have one entity with a good amount of custom fields and we have developed a web resource for the main form. Many of the fields have an onchange event associated with them. Now, we have a new requirement where we need to implement a similar kind of form with some new functionality for different types of users and some of the existing methods also need to be modified. The requirement is to replace the new form JS library with updated new JS library but without removing dependent handlers (as we are using many onchange event handlers as is) with minimum effort.

Solution

I don’t see a direct way to implement the above requirement, so I used the following workaround.

Let’s first create our custom solution and add our entity into solution using "Add Existing" button under solution toolbar. After that, we can open entity form editor and make copy of form using "Save As" like following:



Let’s say we saved it as “Customer Details- Vendor”. Now, we need to copy the existing form JS library code and need to create a new web resource in the same solution. Once the new web resource is created, we will add it to the new form using "form properties" dialog.



Now, export your solution and unzip it. We need to open Customization.xml file into some XML editor. We are using Visual Studio here. Navigate to FormXml node under Entity node. We need to look for forms node where type is main;  we should see two child nodes there -one for information form and onother one for our new form.



Delete the first library reference, which is there for old library, and also replace the library name under onchange event handlers.



Now, select all the files and right click on mouse to compress it using the following option.



Make sure to rename the zip folder with original solution name; for example “HIMBAPDevSolution_1_0.zip” and finally, import this solution to your organization and publish your changes.

Now, we can do other modifications to new JS web resource and add/remove fields to our new form.


Similar Articles
HIMBAP
We are expert in Microsoft Power Platform.