Trying to create a script record for a client scri...
# suitescript
e
Trying to create a script record for a client script and I'm getting this weird error - ReferenceError: XMLHttpRequest is not defined (N/https.js#68) stack:[]. The client script works fine in my dev box (dev not sandbox) and I'm trying to create it in the sandbox. The only difference I see is that my dev env is 2023.2 while my SB is 2023.1. Anyone else encountered this type of error? I deployed my scripts to Release Preview which is on 2023.2 but I am getting the same error message. The other main difference is that PROD and SB are OneWorld while DEV is not OneWorld but I don't understand how that would necessarily affect the https module which seems to be the source of the error message.
b
that sounds like your code uses N/https while defineing itself
e
I took out the N/https reference and it is now complaining of a different error like window undefined or parent.document undefined...all vanilla JS references.
b
the suitescript engine is trying to evaluate the script to determine which entry points it implements
and is failing since while doing so you are trying to use the dom
all these things you use exist in browsers, but dont exist on the server
e
yeah but why does it work in the DEV environment and not the others? It's the same Chrome browser and yes it's client side code.
b
browser is irrelevant, that code is running serverside
it is however possible to write a script that passes server side validation initially, and then fails the validation as you change it
e
well it turns out that since i was redeploying the code to a different environment, NS got confused when it encountered invalid references to files from the previous environment and return the false positive error message. i removed the N/https and re-uploaded that and then re-added the N/https module and fixed the file references in the client script and it's all working out fine now.