"- The enhanced fix for Defect 532599/533207 has b...
# suitescript
s
"- The enhanced fix for Defect 532599/533207 has been released into all accounts" (2019.1 AMD bug)
👍 1
j
I'm still noticing
Uncaught Error: Mismatched anonymous define() module: function(e){return c(e,window,document)}
, hopefully the update will fix the issue shortly though.
d
I get the same issue
s
Do you have both SS1 and SS2 client scripts in play?
j
I just have SS2 scripts for this particular instance of the error.
s
that may be related but perhaps not
do you have multiple SS2 scripts by chance?
loaded simultaneously?
j
It's just the one script although it loads external libraries which I assume is partially the issue.
b
that error generally should only appear for external libraries that are somehow added via a script tag
it shouldn't appear if the external library is added via the dependency parameter of a require or define
j
I've tried adding it in the define statement and it the Mismatched error no longer appears but it seems my library isn't loading correctly. It's Data Tables and requires jQuery so wondering if that is the cause.
b
wait a minute
i remember you
you would have had to use a require config
and map jquery to use data tables properly
did you do that?
j
I have not done that. Excuse my ignorance but how would I go about doing that? This used to just work with it being added with a script tag, this is something I've inherited so don't know the particular reasons for choosing the script tag in the first place.
b
data tables requires a module named 'jquery'
NetSuite forces you to use require configs to use named modules
you can setup your client script to use require configs as detailed in NetSuite's help under "require Configuration" or you can modify the data tables library to use a file cabinet path to jQuery instead
j
I'll have a look at require configuration, thanks!
b
keep in mind that NetSuite require you to use the context key in your config. The context key is a unique id identifying your config
j
I just use a json file in cabinet to map paths and reference it using
@NAmdConfig
pragma
b
you will also probably want to set the paths key. Keep in mind it must be an absolute file path.
j
So I've had a look at the documentation and as far as I can see I was already doing this, I added my file to the amd config and had this in the header of my file. It adds the library but it's not adding the functionality to jquery, I feel like I'm missing something here.
b
what did your config look like, and what does your define look like
j
So my define is like this
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 * @NModuleScope Public
 * @NAmdConfig /SuiteBundles/Bundle 247014/amdConfig.json
 */
define(['N/currentRecord', 'N/search', 'lodash', 'dataTables'],

function(curRecord, search, lodash, dataTables) {
and my config file is
Copy code
{
  "baseUrl": "/SuiteBundles/Bundle 247014/",
  "paths": {
    "lodash": "NETMFG001_lodash.min.js",
    "moment": "NETMFG001_moment.js",
    "dataTables": "jquery.dataTables.min.js"
  }
}
j
try putting jquery in that config file too
j
I shall give this a go
Do I need to add jQuery in my define?
b
no
id also check if something else was adding data tables via script tag to your record
that code above shouldn't add data tables via script tag
j
I've removed all other references to data tables, this is the only way it's being added now
I've added jQuery to my config file and it doesn't throw any mismatched define errors but now jQuery().DataTables() is not a function
b
it shouldnt be
jQuery is a global
amd is specifically designed to avoid that
you access data tables via dataTables
j
I liked when this just worked. I don't understand how I'm supposed to call the data tables initializer without it being attached to jQuery.
jQuery('table#matchedtransactions').DataTables({});
is how I'm supposed to initialize the table. Not sure how I would accomplish that without the function being added to jQuery.
b
there should be an internal reference to jQuery in DataTables
dataTable.$
which you can use, alternativly you can include jQuery in your define
j
Well something seems wrong with mine then as there is no internal reference to jquery, I'll continue investigating though, thanks for the time @battk