Update Entity Form JS Library without removing event handlers- Quick Workaround

Requirement: – Let’s say we have one entity with good amount of custom fields and we have developed a web resource for main form. Many of the fields have onchange event associated with them. Now we got new requirement where we need to implement similar kind of form with some new functionality for different type of users and some of the existing methods also need to be modified. The requirement is to replace 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 efforts.

Solution:- I don’t see a direct way to implement above requirement so I used 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 can make copy of form using Save As like following:

formscript1

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

Now export our solution and unzip exported solution zip folder. 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 one for our new form.
formscript3

Delete first library reference, which is there for old library and also replace library name under on change event handlers.
formscript4
Now select all the files and right click on mouse to compress it using following option:
formscript5

Make sure to rename 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 modification to new JS web resource and add/remove fields to our new form.

One thought on “Update Entity Form JS Library without removing event handlers- Quick Workaround

  1. Pingback: Update Entity Form JS Library without removing event handlers- Quick Workaround - Microsoft Dynamics CRM Community

Leave a Reply