I want to use a third party library that I am test...
# general
l
I want to use a third party library that I am testing in a clientscript, I have the library uploaded to the file cabinet, however when I try to save my script I get the error: "ReferenceError: document is not defined [at /SuiteScripts/lib/qrcode.min.js115894], can someone help me with suggestions on how to solve?
1
r
Did you drop the library file in suitescript folder? You need to create a folder inside suitescript folder, name it as lib and upload the library file in that folder Folder path where your file should be: Suitescript/lib/
l
Yes I do have the library files in a separate lib folder
n
That's pointing to an error in your library script not the script that's referencing it. looks like an issue with scope as its' grumbling it does not know what "document" is. I don't have an answer as to how to resolve it but maybe it'll help to look in to that.
s
Many third-party libraries don’t work with SuiteScript because they either depend upon browser/client features, or features only found in Node. What does this library do? Are there any alternatives you could use instead?
l
This library is qrcode, I actually am trying to implement an example I've been following from SW this past fall where I have access to the source code
b
qrcode is too general a name to guess the module
the guess here is that it is incompatible with suitescript since it uses document while defining itself
document doesnt exist in serverside suitescript, so you get that error
pick a better qrcode library and use that instead
if you have to use that library. then you can use require and only require it when document is not undefined
l
What is confusing about this to me, is that this is running on a client script, and I also have the full source code and have a screen capture of this code working in a NS live enviroment
I am basing mine on the "Method 1" folder within src
b
NetSuite has to actually run and evaluate the script file to determine which entry points it uses
its how script records automatically know which entry points are being used without you selecting any of them
the script evaluation is basically triggered inconsistently depending on the method used to create/edit the script
for example, the ui will always trigger that script evaluation where there are no window related variables
this project was designed to be deployed via sdf. which triggers a different evaluation where it doesnt actually appear to run the script
l
Thank you I appreciate the detailed response 👍