Record Types Enumeration

A particularly important part of working with records is being able to specify which type of record you want to work with.

Whenever we need to create, load, copy, delete, or transform a record, we need to specify which type of record we’ll be working on. Every record type has its own internal ID, which you can find at the top of its page in the Records Browser.


In SuiteScript 1.0, we basically had to memorize this ID for each type of record and use that when specifying a record:

var order = nlapiLoadRecord("salesorder", 123);

In SuiteScript 2.0, we get a more standardized way of referencing record types from the N/record module via the record.Type enumeration.

Aside: In JavaScript and SuiteScript, there is no formal construct for enumerations like there are in most other programming languages, so instead we just fake it with a flat Object like:

var fruits = {
  APPLE: 1,
  ORANGE: 2,

if (myFruit == fruits.APPLE) {
  // We have an apple

N/record defines a similar enumeration for all the record types, and we use it to define the type when loading, creating, deleting, copying, or transforming a record, like so:

var order = r.load({
    type: r.Type.SALES_ORDER
    id: 123

r.Type.SALES_ORDER is one of our enumerated record types that represents the Sales Order record type; each record type has an enumerated value, and you can find all of the enumerated values in the Help on the page titled record.Type underneath the N/record module’s page.

{"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