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

January 7, 2021

Anything I wrote today about business would both feel and be inadequate. I simply can’t arrive at the words to express how I feel in this moment. So instead, here are a few helpful ...

Read More

December 20, 2020

2020 was a hundred swift kicks to the shorts and one giant kick in the ass. If you’ve lost people you love, if you’ve gotten sick or hurt, if you’ve lost your job, if ...

Read More

December 16, 2020

“I’ve been meaning to learn SuiteScript, but it’s hard to find the time …”“We’re slammed, and I just don’t have the time …”“I haven’t made the time …” All are variations of a theme ...

Read More

December 14, 2020

Last week we looked at mimicking the functionality of a REST endpoint with its own module (e.g. retrieving a User, or a list of Users, refreshing a token, etc). For complex integrations that rely on a large ...

Read More