when I want to try small bits of 2.0 code in the c...
# suitescript
w
when I want to try small bits of 2.0 code in the chrome console, I load each module manually with:
Copy code
require("[N/record"])
var record = require("N/record")
Is there some way to load all common modules with a snippet or something? Anyone got a tip for their awesome way?
Realized I can maintain two lines instead.
Copy code
var record,search,format,query;
require(["N/record","N/search","N/format","N/query"],function(recordMod,searchMod,formatMod,queryMod){record = recordMod;search=searchMod;format=formatMod;query=queryMod});
b
Copy code
require(['N'], function(N) {Object.assign(window, N)})
👍 1
that said, I dont usually make the netsuite modules global and just use them inside the require function
w
Ok, so that is basically the same, but I don't need to declare the globals outside of the callback?
Yeah, I usually write snippets and execute if it's more of a function. But sometimes I just want run some line of code.
b
in this case, Object.assign is being used to merge the N object containing all the public netsuite modules into the window global
w
ohhhhh
I thought you just meant I should substitute for all modules separately
b
its not as nice for modules like N/ui/dialog, which is buried a little deeper than you would do manually
w
But damn, that's nice :)
b
not entirely mine, using N came from somewhere else in the channel. as i said, i dont bother with the globals
m
Chrome has a useful feature called Snippets which makes it really easy to create ad-hoc multi line scripts. I also figured out a way to load the require.js framework on any page in NetSuite, not just record pages in edit mode..
☝️ 1
👍 1
s
Chrome snippets is how I do it as well, as michoel pointed out