{"id":5425,"date":"2017-05-10T18:06:08","date_gmt":"2017-05-10T12:36:08","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=5425"},"modified":"2021-05-24T12:42:26","modified_gmt":"2021-05-24T12:42:26","slug":"tip-call-javascript-on-change-of-the-field-on-form-in-resco","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2017\/05\/tip-call-javascript-on-change-of-the-field-on-form-in-resco\/","title":{"rendered":"Tip &#8211; Call JavaScript on change of the field on Form in Resco"},"content":{"rendered":"<p><strong>Introduction:<\/strong><\/p>\n<p>Resco Mobile App is a boon for the Field Technicians; it\u2019s crisp, it\u2019s smooth and has a lot of functionalities that could ease the life of a Technician. Resco provides us Form Rules to perform many things in the face of onchange, onload and onsave event on the form.<\/p>\n<p style=\"text-align: justify;\"><strong>Limitations:<\/strong><\/p>\n<p style=\"text-align: justify;\">We could say, Resco Form Rules are more than sufficient for your core and advanced needs.<\/p>\n<p style=\"text-align: justify;\">But, there could be scenarios that are not simple to implement and cannot leverage the OOB Form Rules functionality.<\/p>\n<p style=\"text-align: justify;\"><strong>Workaround:<\/strong><\/p>\n<p style=\"text-align: justify;\">To leverage the OOB Form Rules functionality, we need to resort to the JavaScript option.<\/p>\n<p style=\"text-align: justify;\">Yes, we can have a JavaScript called\/triggered on the change of a field on the Form.<\/p>\n<p style=\"text-align: justify;\">The procedure to implement the JavaScript way is very simple, given that you know how to do that.<\/p>\n<p style=\"text-align: justify;\">Even when we had to implement the JavaScript approach, it took us a while before we could figure out the correct approach.<\/p>\n<p style=\"text-align: justify;\">The steps are pretty simple, as explained below:<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">1.\u00a0We need to create an HTML that would be placed as an iframe on the form.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">2. The HTML should have a reference to the JSBRIDGE.js<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">3. Then based on the onchange event described <a href=\"https:\/\/www.resco.net\/javascript-bridge-reference\/#MobileCRM_UI_EntityForm_onChange\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>, create a function.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">4. Next, you need to call this function on load of the HTML page; this is the most important step.<\/p>\n<p style=\"padding-left: 60px; text-align: justify;\">We initially tried using the $(document).ready, but it didn\u2019t work.<\/p>\n<p style=\"padding-left: 60px; text-align: justify;\">But, after calling the function as below did the trick for us.<\/p>\n<p style=\"padding-left: 60px; text-align: justify;\"><strong>&lt;body onload=&#8221;onLoad();&#8221;&gt;<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">5. Once you have the HTML ready, upload the necessary files to the Offline HTML section of Resco, and on the form create an iframe.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-5426\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/05\/Call-JavaScript-on-change-of-the-field-on-Form-in-Resco.png\" alt=\"Call JavaScript on change of the field on Form in Resco\" width=\"519\" height=\"253\" \/><\/p>\n<p style=\"padding-left: 30px;\">6. While creating an iframe, do not forget to uncheck the Delay Load.<\/p>\n<p style=\"padding-left: 30px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-5427\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/05\/Call-JavaScript-on-change-of-the-field-on-Form-in-Resco1.png\" alt=\"Call JavaScript on change of the field on Form in Resco\" width=\"417\" height=\"321\" \/><\/p>\n<blockquote><p><strong><em>Note: Unchecking the Delay Load makes sure that the HTML is loaded as soon as the form is loaded and hence it facilitates the binding of onchange event.<\/em><\/strong><\/p><\/blockquote>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>Conclusion:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">Within few simple steps, you can easily have a JavaScript called\/triggered on the change of a field on the Form in Resco and leverage the OOB Form Rules functionality.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><a href=\"http:\/\/www.inogic.com\/product\/productivity-pack\/click-2-export-microsoft-dynamics-crm-reports\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4895\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/03\/Marketing-Banner.jpg\" alt=\"Export and Email Dynamics 365 Reports in PDF, Word &amp; Excel format with Click2Export\" width=\"728\" height=\"90\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Resco Mobile App is a boon for the Field Technicians; it\u2019s crisp, it\u2019s smooth and has a lot of functionalities that could ease the life of a Technician. Resco provides us Form Rules to perform many things in the face of onchange, onload and onsave event on the form. Limitations: We could say, Resco\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2017\/05\/tip-call-javascript-on-change-of-the-field-on-form-in-resco\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":5444,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[33,48],"tags":[970,1445,1447],"class_list":["post-5425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-resco-mobile-crm","tag-java-script-in-resco","tag-resco-mobile-app","tag-resco-mobile-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/5425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=5425"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/5425\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/5444"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=5425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=5425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=5425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}