Welcome to our blog where will be sharing tip, tricks and detailed walk-throughs covering all areas of Dynamics 365 but primarily focused on the Field Service and Project Service Apps, Scheduling and integration using Microsoft Flow and the Common Data Service (CDS). We hope you find the blog posts useful and please feel free to comment if you would like us to elaborate on any particular area. 

Quick Tip to help resolve JavaScript errors post-upgrade of PSA and/or Field Service solutions.

I recently had a bug reported on the "out of the box" Order form (Project Information) in a PSA 3.7 environment which was recently upgraded from a previous version and which contained a managed solution where we have customized that form as part of our Accelerators. The bug only occurred on save of a new Project Contract (as shown below) and did not happen in a clean PSA 3.7 instance which meant it had to be related to our managed solution. However, after spending quite a bit of time trying to locate the source of the error I was getting quite frustrated.

As it turns out the problem was caused by an "OnChange" event handler on the Order ID which had been included in previous PSA releases but removed in the latest version. However because we had customised the form the event handler had not been removed after upgrading (you would experience similar issues if you copy "out of the box" forms too) and gave rise to the error I was getting as the "initializeGrid" method no longer existed in the applicable "ContractView" JavaScript library.

Seems obvious now but at the time I didn't think about checking the "out of the box" fields for "onchange" events which may have been removed.

Now, to try and help you locate the issue much faster than I did I thought it would be good to share how I actually managed to track this down as it would've saved me an awful lot of time!

These are the steps I took to locate the issue:

  1. Created a brand new unmanaged solution in my environment and just added the Order entity meta-data and the "Project Information" form which was the form I was having the issue with

  2. Exported the new solution and saved locally to a temp folder on my PC.

  3. Unzipped the solution file into it's constituent parts so i could search the FormXml.

  4. Opened the "customizations.xml" and searched for the offending missing method "initializeGrid".

And sure enough it pointed me exactly where I needed to go and the issue was fixed by simply removing the event handler which was no longer applicable.

Hopefully this will save you time if you run into similar issues and aren't sure where the problem lies.

83 views0 comments