This topic contains 6 replies, has 1 voice, and was last updated by Troy 7 years, 3 months ago.
-
AuthorPosts
-
February 9, 2017 at 3:33 pm #1182
WakaWakaHas anyone ever seen this before? I can’t find any information on such a thing. The first time it happened, I was able to fix it by removing some references to modules that weren’t being used in my code anymore. By that I mean something like removing ‘N/log’ in define([‘N/log’], function(){});
Shortly after, it happend again, although this file doesn’t even use any of the Netsuite modules!!
This is a cached copy. Click here to see the original post. -
February 9, 2017 at 4:12 pm #1183
WakaWakaAh, I understand the problem now, I think.
My file referenced a file that referenced a file that had some code running before the return statement ran (that return statement contains all the available function to be invoked on the module).
In that code before the return statement, I had a call to the log module. After removing that log statement, my problem was fixed.
So really, the error message does make sense, once you’ve figured out what it means anyways haha.
Hopefully that explanation is good enough. Otherwise I can try to add more detail or post some code.
EDIT: The file that referenced the file containing the log statement? The function I was calling from that file was a self executing function, because I had some variables I wanted to be “private”. Thus, it wanted to execute the log statement (I assume).
-
August 4, 2017 at 12:48 am #16398
This was helpful in resolving an issue where I encountered this error while saving a 2.0 script via the UI. Thank you.
-
-
February 25, 2017 at 3:54 am #1184
chanarbonFrom what I see from my testing, if you placed an initialization inside the main callback function and is referred within the functions used by the entry points, you may encounter this concern.
-
February 27, 2017 at 8:00 am #1185
Jarod TavaresI’ve been bumping into this regularly. Sometimes it makes sense for a module to maintain some internal private state or do what passes for meta-programming in ES5. My scripts may work as intended, but NetSuite doesn’t seem to appreciate such cleverness when editing scripts from the web. I end up having to back out and do things “the hard way” because I can’t sacrifice the web-editor.
It’s too bad, given the new CodeMirror-based editor has been so nice for one-off experiments and quick emergency fixes. Wish there was some leeway between protecting us from ourselves and encouraging cowboy coding.
-
February 27, 2017 at 8:07 am #1186
chanarbonThis actually happens as well when you are creating a newly uploaded script with the scenario the I have mentioned e.g.
Code:
define([], function(){var a = 0
function myFieldChangedFxn(context){
var currentRecord = context.currentRecord;
var x = a;
var sublistId = context.sublistId;
var fieldId = context.fieldId;if(sublistId == “item” && fieldId == “item”){
…….
}}
return {
fieldChanged : myFieldChangedFxn
}})
where in a was from the main callback and was called on a callback function -
April 3, 2017 at 7:19 pm #1187
cblackburnEssentially, the callback to define is a constructor for the module itself, which may be called in advance of triggering the module’s entrypoint functions. The check is protecting script authors from having any code with side effects on the system run at unexpected times, nothing to do with encapsulation.
Wrapping setup code in a lazy loading function which is called from entrypoint functions is one solution.
-
AuthorPosts
You must be logged in to reply to this topic.