June 19, 2017

8 SuiteScript 2.0 in the Console

In this edition, we take a brief look at how to test out SuiteScript 2.0 code in our browser console.

We can use our browser’s Developer Tools in order to quickly test and experiment with SuiteScript without creating an entirely new Script.

In SuiteScript 1.0, all of our functions and Objects were available globally, so you could just pop open the console and start using SuiteScript. The module structure of SuiteScript 2.0 adds just a step or two to this process.

In order to work with a 2.0 module in the console, we need to import it into the console context first. We do that using the require function:

Note this looks a little like a normal module definition, except we use require instead of define, and we don’t need to define a callback function.

This statement simply makes the specified modules available to load in the console; they haven’t actually been loaded yet. If you have not yet run this statement to make the module available, you will receive this error when you try to load it:

We can now use require again to actually load each module:

Once loaded, we can use these modules just like we would from within a script. For instance, I can use the currentRecord module to retrieve field values from the record:

Or I can use the message module to display a message to the user:


You will want to be aware of a couple limitations of SuiteScript in the console.

First, not all modules are available client-side. If you try to load a module that is not available, you will receive a “load timeout” error:

Second, you can only run SuiteScript in the console from a page that already supports SuiteScript. I typically go to the entry form for a new record, like a Sales Order or Customer. If you try to load a module on a page that does not support SuiteScript, you will receive the following error:


That’s all there is to it. Hopefully this makes your SuiteScript 2.0 testing and experimentation just a bit faster and easier.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Related posts

March 3, 2021

Does the physical location of a competent employee change the amount of value they can deliver for your organization? If it does, I’d be keen to hear your story. If it does not, why ...

Read More

March 2, 2021

Today a friend and former colleague of mine – who happens to now be in a development leadership role for a NetSuite partner – was lamenting the extreme difficulty of finding and hiring NetSuite ...

Read More

March 1, 2021

Software is never finished; clients are always changing and re-prioritizing. NetSuite is ever a moving target – always updating and evolving. Market forces are always shifting and shoving, forcing new demands on your business. ...

Read More