Expand your SuiteScript skills in the Sustainable SuiteScript community for NetSuite developers.

Rapidly Inspect NetSuite Record Data in the Browser Console

Created: February 25, 2025

An undocumented SuiteScript method can help you inspect data from the current NetSuite Record using the browser console.

require(['N/record'], a => r = a)
r.load({ type: nlapiGetRecordType(), id: nlapiGetRecordId() }).toJSON()

Run this code in the browser console on the EDIT-mode page of the record to be inspected. It will not work in VIEW mode.

Here's a breakdown of this code:

require(['N/record'], a=>r=a) imports the N/record module as r.

r.load({type:nlapiGetRecordType(), id:nlapiGetRecordId()}) loads the current record using the global SuiteScript 1.0 methods to retrieve the current record type and ID.

⚠️ Do not mix your 1.0 and 2.x like this in Production code; this is just a quick troubleshooting/prototyping technique

.toJSON() is an undocumented method on the Record instance which transforms the Record instance into a plain JavaScript object. This can then be easily inspected in the console:

Record instance data shown in the browser console

Technically, toJSON() isn't undocumented; it's just not documented by NetSuite. The toJSON() method is a convention in JavaScript used by the JSON.stringify() function:

JSON.stringify() will always look for a toJSON() method on any object it serializes and prefer that when performing its serialization.

You can read more about this behavior on MDN.

Note that this technique really only helps us view the data on a Record. We cannot use the resulting object to write data back to NetSuite; for that, we still need to use the normal methods on the Record instance directly (e.g. setValue()).

If you want to do this with all 2.x instead, it might look more like:

require(['N/record', 'N/currentRecord'], (a, b) => {
  record = a;
  currentRecord = b;
})
cr = currentRecord.get()
record.load({ ...cr }).toJSON()

The CurrentRecord instance cr already has the appropriate type and id properties on it, so we can destructure it for the input to record.load().

Unfortunately, the CurrentRecord instance does not have a toJSON() method, so we still need to load the Record instance.

Bonus points for saving this as a Snippet in your console for easy reuse later.