Hi, I am looking to import the custom library <lis...
# suitescript
l
Hi, I am looking to import the custom library list.js, however I keep getting the following error whe trying to reference the script in my clientScript "ReferenceError: window is not defined", can someone help me understand what this error is saying, and how to fix it?
What is strange is that I have already gotten the chartjs library to work within netsuite, and this library has window references in it but that is not causing me any issues.
m
Sounds like it depends on if your using on a client side or server side script. It will probably cause errors on server side scripts, but work fine on client side scripts. Just a guess though.
b
chart js does things like
Copy code
function _isDomSupported() { return typeof window !== 'undefined' && typeof document !== 'undefined'; }
so its aware that it can run in environments without window
list js doesnt
l
Does this mean that I am unable to use an library that has references to window within it, or are there workarounds for this?
b
scripts uploaded via the ui always cause netsuite to evaluate the script on the server
scripts via sdf usually dont
so if you want to leave your script in an indeterminate state for the next person, you can use sdf and not use the ui
otherwise the alternative is to only require list js when window is defined