Has anyone used the query module in the chrome con...
# suitescript
a
Has anyone used the query module in the chrome console (developer tools, not using script debugger in 2.1)? The help center says it works both client side and server side but I am getting undefined when I am trying to load it in the chrome console
s
yep used it plenty of times in chrome console
Are you on an actual record? You cannot load the modules on just any page in NS (regardless or which one).
a
Yes. I am on a record
c
Can you share the code?
a
This was the snippet someone shared here a long time ago
Copy code
var record, curecModule, currentRecord, search, query, runtime, xml, format, email, https;
require(['N/record', 'N/currentRecord', 'N/search', 'N/query', 'N/runtime', 'N/xml', 'N/format', 'N/email', 'N/https'],
  function (r, c, s, q, u, x, f, e, h, q) {
    record = r
    email = e
    currentRecord = c.get()
    search = s
    runtime = u
    xml = x
    format = f
    curecModule = c
    https = h
    R = ramda
    dms = dmsearch
    query = q

    console.log("2.0 Modules Loaded!");
  });
Other modules are working
But not query
s
Copy code
require(['N/query'], function (query) {
    window['query'] = query;
})
see if that works
you can probably find the problem in your snippet,
q
in the function call twice
🙌 1
function (r, c, s, q, u, x, f, e, h, q, ramda, dmsearch)
a
Ah! You are right
Thanks!
b
whoever shared your code has no imagination
Copy code
require(["N"], function (N) {
  Object.assign(window, N);
});
😍 1
gets all the modules on the global variable
the ones at the second level (like N/ui/dialog) wont be as nice, but still usuable
a
Nice! I didn't realize that N was an object that had all the modules
Once we are being so fancy make it a one liner
Copy code
require(['N'], N => Object.assign(window, N))