How to resolve jQuery issue with 2019.2 SuiteScript 2.0 portlet script?
In 2019.2 there have been some changes on NetSuite’s side that are causing some jQuery libraries to not work correctly for SuiteScript 2.0 scripts. jQuery v. 2.1.3 and jQuery-UI v. 1.11.4 are being utilized. The issue is primarily with DataTables, as it will return an error of ‘$(…).DataTable is not a function’, however this was never an issue in 2019.1
I’m hoping that someone else has also encountered this issue, and may have come up with a solution?
Example of how the libraries are being added to the script (with exception of jQuery and jQuery-UI):
I’ve had this issue in the past, in my experience it is more having to do with the jQuery library not having been loaded previously to the other library which holds jQuery as a dependency. If you are injecting libraries via html as you have shown, you could try explicitly loading your version of jQuery first.
Or (I think more best practice) uploading the jQuery and other library scripts into NetSuite file cabinet and referencing via config.json and
@NAmdConfig script tag. For this option, I have needed to have jQuery in config.json file using the shim section and listing it in deps for other scripts. See https://requirejs.org/docs/api.html#config-shim for reference.