As you all know with an interpreted language like javascript the order of things in your code can really make a difference.
I've been getting client side errors on a new system I've been developing and after a couple hours I found out the problem: NetSuite is rendering the Library Script File tag AFTER the main Script File.
To verify this I made a simple example with an html file and two js files. Here are their contents:
library.js
var OBJ_LOCATED_IN_LIBRARY_FILE = { NAME : 'I am a value from the library file', } stuff.jsvar CLIENT = { NAME: OBJ_LOCATED_IN_LIBRARY_FILE.NAME, } function stuff() { alert(CLIENT.NAME); } duh.html <html> <head> <script type='text/javascript' src='stuff.js'></script> <script type='text/javascript' src='library.js'></script> <script> stuff(); </script> </head> <body> <h1>Uhmm....?</h1> </body> </html>
When you open duh.html you will see this in the FF error console:
Error: OBJ_LOCATED_IN_LIBRARY_FILE is not defined
Source File: file:///C:/Documents%20and%20Settings/sklett/Desktop/js%20ordering%20test/stuff.js
Line: 3
Error: CLIENT has no properties
Source File: file:///C:/Documents%20and%20Settings/sklett/Desktop/js%20ordering%20test/stuff.js
Line: 8
Swap the order of the script tags and everything works fine.NetSuite: Assuming you agree the current behavior is illogical.. how long to correct it? I've got a pretty big implementation (3000+ lines) hanging in limbo right now.I'm also no html/javascript pro, so if there is some other clever workaround I would love to know it. However I don't want to change from initializing literals with other objects...