I had a situation where I thought the NS debugger ...
# suitescript
s
I had a situation where I thought the NS debugger would be useful, but I keep getting this error. Any ideas?
this is trying to do ad-hoc SS2.1 code
j
sounds like a setting in developer tools might be disabled
a
I believe that either means you didn't put a breakpoint or you have a syntax error. Click on the console tab. It should give you an error message
I use this snippet for both the chrome console and the Netsuite script debugger (using 2.1 only) Thanks to @battk for the idea
Copy code
require(['N'], (N) => {
	if (typeof window == 'object') return Object.assign(window, N)

	const { search, record, log } = N


	var stopper = 0
})
s
wait, unrelated question, does that work only with these pseudo paths (i.e. 'N') or can we require entire folders of custom code in the same fashion?
s
Yes, I vaguely recall trying this back when 2.0 was released, but it (netsuite) didn't seem to support it
b
at the very least it works clientside, its how you get highcharts to work
a
It works for both. I usually have other libraries here, but I took it out to post in the snippet here.
But if you do that you will need to spread all your variables to the object.window for the chrome console part
Object.assign(window, {...N, otherLibraryHere})
s
I was talking specifically about server side loading of an entire folder. I'll have to try it out again I suppose. thanks for pasting that here Azi else I would assume it just didn't work.
b
packages are a way to give an alias to a folder
with a main module whose alias matches the alias of the folder
netsuite implemented an N package, with a main module that returns an object containing a reference to all the other modules
a
Oh. Now I think I understand what you are asking. I was talking about files not folders.