{"id":2717,"date":"2017-06-30T11:02:34","date_gmt":"2017-06-30T11:02:34","guid":{"rendered":"http:\/\/himbap.com\/blog\/?p=2717"},"modified":"2017-06-30T11:02:34","modified_gmt":"2017-06-30T11:02:34","slug":"update-entity-form-js-library-without-removing-event-handlers-quick-workaround","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=2717","title":{"rendered":"Update Entity Form JS Library without removing event handlers- Quick Workaround"},"content":{"rendered":"<p><strong>Requirement<\/strong>: &#8211; Let\u2019s 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.<\/p>\n<p><strong>Solution<\/strong>:- I don\u2019t see a direct way to implement above requirement so I used following workaround.<br \/>\nLet\u2019s first create our custom solution and add our entity into solution using <strong>Add Existing<\/strong> button under solution toolbar. After that we can open entity form editor and can make copy of form using Save As like following:<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript1.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2718 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript1-300x139.png\" alt=\"formscript1\" width=\"300\" height=\"139\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript1-300x139.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript1.png 416w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Let\u2019s say we saved it as \u201c<strong>Customer Details- Vendor<\/strong>\u201d. 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.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript2.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2719 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript2-300x63.png\" alt=\"formscript2\" width=\"300\" height=\"63\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript2-300x63.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript2.png 441w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>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 <strong>FormXml<\/strong> 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.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript3.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2720 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript3-300x140.png\" alt=\"formscript3\" width=\"300\" height=\"140\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript3-300x140.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript3-624x290.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript3.png 909w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Delete first library reference, which is there for old library and also replace library name under on change event handlers.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript4.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2721 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript4-300x218.png\" alt=\"formscript4\" width=\"300\" height=\"218\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript4-300x218.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript4.png 583w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nNow select all the files and right click on mouse to compress it using following option:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript5.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2722 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript5-300x145.png\" alt=\"formscript5\" width=\"300\" height=\"145\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript5-300x145.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2017\/06\/formscript5.png 609w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Make sure to rename zip folder with original solution name for example \u201cHIMBAPDevSolution_1_0.zip\u201d and finally import this solution to your organization and publish your changes.<br \/>\nNow we can do other modification to new JS web resource and add\/remove fields to our new form.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requirement: &#8211; Let\u2019s 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&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=2717\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[402,275],"tags":[442,441],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2717"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2717"}],"version-history":[{"count":3,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2717\/revisions"}],"predecessor-version":[{"id":2725,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2717\/revisions\/2725"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}