Can anyone help me plug JQUERY to SS2.0 . Based on...
# suitescript
n
Can anyone help me plug JQUERY to SS2.0 . Based on the NetSuite documentation I have created a JSON file that has this code which points to my Jquery file path in the file cabinet...
Copy code
{
  "paths": {
    "jquery": "SuiteScripts/SuiteScript 2.0/JS_Libraries/jquery-3.3.1.js"
  }
}
Now on a SS2.0 user event, I include the AMD tag like this:
Copy code
/**
@NApiVersion 2.0
@NScriptType usereventscript
@NAmdConfig ./JsLibraryConfig.json
@ModuleScope Public
*/
define(["N/search", "../SuiteScript 2.0/JS_Libraries/moment.js", "jquery"], function (se, m, jquery){
But this keeps failing with an error like this:
Copy code
{
  "type": "error.SuiteScriptModuleLoaderError",
  "name": "TypeError",
  "message": "Cannot call method \"createElement\" of undefined",
  "stack": "\tat /SuiteScripts/SuiteScript 2.0/JS_Libraries/jquery-3.3.1.js:882 (assert)\n\tat /SuiteScripts/SuiteScript 2.0/JS_Libraries/jquery-3.3.1.js:2701\n\tat /SuiteScripts/SuiteScript 2.0/JS_Libraries/jquery-3.3.1.js:499\n\tat /SuiteScripts/SuiteScript 2.0/JS_Libraries/jquery-3.3.1.js:36\n\tat /SuiteScripts/SuiteScript 2.0/JS_Libraries/jquery-3.3.1.js:14\n\tat INVOCATION_WRAPPER$sys:19\n\tat INVOCATION_WRAPPER$sys:31\n\tat INVOCATION_WRAPPER$sys:1\n"
}
Does anyone know what I may be doing wrong?
j
@NSObsessed Building off of what antoko said, the stack trace of the error references line 882 of jquery-3.3.1.js, which is
var el = document.createElement("fieldset");
Your script is a usereventscript which runs on the NetSuite server and has no global
document
variable.
e
Indeed; what are you using jquery for on the server side?
n
good point. I was just trying to test attaching jquery as a module thats all. Let me try to plug it into a client script
👍🏼 1
its working on client side now. I should have figured that one out, i just didnt think about what type of script i was trying to add the jquery module on and if that made any sense at all. Thank you for your help.
e
np glad you've got it; good catch @jkabot