I'm having a weird issue. If I have a helper file ...
# suitescript
s
I'm having a weird issue. If I have a helper file that is returning runtime.envType, when I call I include that module in my main js file, and try and upload it via SDF in webstorm, I am getting
There was a problem when uploading the file. Details: Fail to evaluate script: {"type":"error.SuiteScriptError","name":"SUITESCRIPT_API_UNAVAILABLE_IN_DEFINE","message":"All SuiteScript API Modules are unavailable while executing your define callback.","stack":["Error\n    at getFileId (/SuiteScripts/AccentDecor/Libs/Config/fileConfig.js:7:19)\n    at /SuiteScripts/AccentDecor/Libs/Config/fileConfig.js:22:29"],"cause":{"type":"internal error","code":"SUITESCRIPT_API_UNAVAILABLE_IN_DEFINE","details":"All SuiteScript API Modules are unavailable while executing your define callback.","userEvent":null,"stackTrace":["Error\n    at getFileId (/SuiteScripts/AccentDecor/Libs/Config/fileConfig.js:7:19)\n    at /SuiteScripts/AccentDecor/Libs/Config/fileConfig.js:22:29"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":true}.
However, if I include runtime in the mail file, and return runtime.envType it works. Either scenario works if I have both js files in sandbox, it's just SDF Webstorm is messing up for some reason. It is happening when doing the below. I would like to keep this as it makes it easier to type when reused.
Copy code
return {
    SCRIPT_SAVED_FILES: getFileId('SCRIPT_SAVED_FILES')
};
b
netsuite evaluates the script file to determine things like what entry points it exposes
you get that error when your script uses any of suitescript's api
in this case, including the library file also means netsuite evaluates the library file
there are workaround to trick netsuite, but that just screws the next person
just fix the script so that it doesnt use any suitescript modules when evaluated
s
Yeah, that's what I did. Creating several methods instead of one that I can just recall 😢
b
the code you had would have been fine if you made it return a function
s
Well I don't want to do something like folderConfi.getFileId(folderConfig.Folders.ScriptFiles) So I changed it to folderConfig.ScriptFiles() to be shorter.