N/record Module

Use the N/record module to work with NetSuite records. You can use this module to create, delete, copy, load, or make changes to a record.

                                   

SuiteScript supports working with standard NetSuite records and with instances of custom record types. Supported standard record types are described in the SuiteScript Records Browser. Refer also to SuiteScript Supported Records. For help working with an instance of a custom record type, see Custom Record.

For help finding a record’s internal ID, see Finding Internal IDs of Records.

Important:

SuiteScript does not support direct access to the NetSuite UI through the Document Object Model (DOM). The NetSuite UI should only be accessed with SuiteScript APIs.

In This Help Topic

N/record Module Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

record.Column

Object

Client and server scripts

Encapsulates a column of a sublist on a standard or custom record.

record.Field

Object

Client and server scripts

Encapsulates a body or sublist field on a standard or custom record.

record.Macro

Object

Client and server scripts

Encapsulates a NetSuite record macro.

Plain JavaScript Object

Object

Client and server scripts

A plain JavaScript object of record macros available for a record type. This object is returned by Record.getMacros().

record.Record

Object

Client and server scripts

Encapsulates a NetSuite record.

record.Sublist

Object

Client and server scripts

Encapsulates a sublist on a standard or custom record.

Method

record.attach(options)

void

Client and server scripts

Attaches a record to another record.

record.attach.promise(options)

Promise

Client scripts

Attaches a record asynchronously to another record.

record.copy(options)

record.Record

Client and server scripts

Creates a new record by copying an existing record in NetSuite.

record.copy.promise(options)

Promise

Client scripts

Creates a new record asynchronously by copying an existing record in NetSuite.

record.create(options)

record.Record

Client and server scripts

Creates a new record.

record.create.promise(options)

Promise

Client scripts

Creates a new record asynchronously.

record.delete(options)

number

Client and server scripts

Deletes a record.

record.delete.promise(options)

Promise

Client scripts

Deletes a record asynchronously.

record.detach(options)

void

Client and server scripts

Detaches a record from another record.

record.detach.promise(options)

Promise

Client scripts

Detaches a record from another record asynchronously.

record.load(options)

Object

Client and server scripts

Loads an existing record.

record.load.promise(options)

Promise

Client scripts

Loads an existing record asynchronously.

record.submitFields(options)

Object

Client and server scripts

Updates and submits one or more body fields on an existing record in NetSuite, and returns the internal ID of the parent record.

record.submitFields.promise(options)

Promise

Client scripts

Updates and submits one or more body fields asynchronously on an existing record in NetSuite, and returns the internal ID of the parent record.

record.transform(options)

record.Record

Client and server scripts

Transforms a record from one type into another, using data from an existing record.

record.transform.promise(options)

Promise

Client scripts

Transforms a record from one type into another asynchronously, using data from an existing record.

Enum

record.Type

enum

Client and server scripts

Holds the string values for supported record types. Use this enum to set the value of the Record.type property in cases where you are working with an instance of a standard NetSuite record type.

Column Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Column.id

string (read-only)

Client and server scripts

Returns the internal ID of the column.

Column.isDisabled

boolean

Client and server scripts

Indicates whether the column is disabled.

Column.isDisplay

boolean (read-only)

Client and server scripts

Indicates whether the column is displayed.

Column.isMandatory

boolean

Client and server scripts

Indicates whether the column is required.

Column.isSortable

boolean (read-only)

Client and server scripts

Indicates whether the column is sortable.

Column.label

string (read-only)

Client and server scripts

Returns the UI label for the column.

Column.sublistId

string (read-only)

Client and server scripts

Returns the internal ID of the standard or custom sublist that contains the column.

Column.type

string (read-only)

Client and server scripts

Returns the column type.

Field Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Field.getSelectOptions(options)

array

Client and server scripts

Returns an array of available options on a standard or custom select, multiselect, or radio field as key-value pairs. Only the first 1,000 available options are returned.

Property

Field.label

string (read-only)

Client and server scripts

Returns the UI label for a standard or custom field body or sublist field.

Field.id

string (read-only)

Client and server scripts

Returns the internal ID of a standard or custom body or sublist field.

Field.type

string (read-only)

Client and server scripts

Returns the type of a body or sublist field.

Field.isMandatory

boolean

Client and server scripts

Returns true if the standard or custom field is required on the record form, or false otherwise.

Field.sublistId

string (read-only)

Client and server scripts

Returns the ID of the sublist associated with the specified sublist field.

This property is available only when working with a record in dynamic mode.

Field.isDisplay

boolean

Client and server scripts

Returns true if the field is visible on the record form, or false if it is not.

This property is available only when working with a record in dynamic mode.

Macro Object Members

The following members are called on the record.Macro object. For information about record macros, see Overview of Record Action and Macro APIs.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Macro.execute(options)

Object

Client and server scripts

Performs a macro operation and returns its result in an object.

Macro.execute.promise(options)

Promise

Client scripts

Performs a macro operation asynchronously.

Macro(options)

Object

Client and server scripts

Performs a macro operation and returns its result in an object.

Macro.promise(options)

Promise

Client scripts

Performs a macro operation asynchronously.

Property

Macro.id

string

Client and server scripts

The ID of the macro.

For a list of macro IDs, see Supported Record Macros

Macro.label

string

Client and server scripts

The macro label.

Macro.description

string

Client and server scripts

The macro description.

Macro.attributes

Object

Client and server scripts

The macro defined attributes.

Record Object Members

The following members are called on the record.Record object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Record.cancelLine(options)

record.Record

Client and server scripts

Cancels the currently selected line on a sublist.

Record.commitLine(options)

record.Record

Client and server scripts

Commits the currently selected line on a sublist.

Record.executeMacro(options)

Object

Client and server scripts

Performs macro operation and returns its result in a plain JavaScript object.

Record.getMacros()

Object

Client and server scripts

Provides a plain JavaScript object that contains macro objects defined for a record type, indexed by the Macro ID.

Record.findMatrixSublistLineWithValue(options)

number

Client and server scripts

Returns the line number of the first instance where a specified value is found in a specified column of the matrix.

Record.findSublistLineWithValue(options)

number

Client and server scripts

Returns the line number for the first occurrence of a field value in a sublist.

Record.getCurrentMatrixSublistValue(options)

number | Date | string | array | boolean

Client and server scripts

Gets the value for the currently selected line in the matrix.

Record.getCurrentSublistField(options)

record.Field

Client and server scripts

Returns a field object from a sublist.

Record.getCurrentSublistIndex(options)

number

Client and server scripts

Returns the line number of the currently selected line.

Record.getCurrentSublistSubrecord(options)

record.Record

Client and server scripts

Gets the subrecord for the associated sublist field on the current line.

Record.getCurrentSublistText(options)

string

Client and server scripts

Returns a text representation of the field value in the currently selected line.

Record.getCurrentSublistValue(options)

number | Date | string | array | boolean

Client and server scripts

Returns the value of a sublist field on the currently selected sublist line.

Record.getField(options)

record.Field

Client and server scripts

Returns a field object from a record.

Record.getFields()

string[]

Client and server scripts

Returns the body field names (internal ids) of all the fields in the record, including machine header field and matrix header fields.

Record.getLineCount(options)

number

Client and server scripts

Returns the number of lines in a sublist.

Record.getMacro(options)

record.Macro

Client and server scripts

Provides a macro to execute.

Record.getMacros()

Object

Client and server scripts

Provides a plain JavaScript object that contains macro objects defined for a record type, indexed by the Macro ID.

Record.getMatrixHeaderCount(options)

number

Client and server scripts

Returns the number of columns for the specified matrix.

Record.getMatrixHeaderField(options)

record.Field

Client and server scripts

Gets the field for the specified header in the matrix.

Record.getMatrixHeaderValue(options)

number | Date | string | array | boolean

Client and server scripts

Gets the value for the associated header in the matrix.

Record.getMatrixSublistField(options)

record.Field

Client and server scripts

Gets the field for the specified sublist in the matrix.

Record.getMatrixSublistValue(options)

number | Date | string | array | boolean

Client and server scripts

Gets the value for the associated field in the matrix.

Record.getSublist(options)

record.Sublist

Client and server scripts

Returns the specified sublist.

Record.getSublists()

string[]

Client and server scripts

Returns all the names of all the sublists.

Record.getSublistField(options)

record.Field

Client and server scripts

Returns a field object from a sublist.

Record.getSublistFields(options)

string[]

Client and server scripts

Returns all the field names in a sublist.

Record.getSublistSubrecord(options)

record.Record

Client and server scripts

Gets the subrecord associated with a sublist field. (standard mode only)

Record.getSublistText(options)

string

Client and server scripts

Returns the value of a sublist field in a text representation.

Record.getSublistValue(options)

number | Date | string | array | boolean

Client and server scripts

Returns the value of a sublist field.

Record.getSubrecord(options)

record.Record

Client and server scripts

Gets the subrecord for the associated field.

Record.getText(options)

string

Client and server scripts

Returns the text representation of a field value.

Record.getValue(options)

number | Date | string | array | boolean

Client and server scripts

Returns the value of a field. Not to be used on custom password fields. Use crypto.checkPasswordField(options) instead.

Record.hasCurrentSublistSubrecord(options)

boolean

Client and server scripts

Returns a value indicating whether the associated sublist field has a subrecord on the current line.

Record.hasSublistSubrecord(options)

boolean

Client and server scripts

Returns a value indicating whether the associated sublist field contains a subrecord.

Record.hasSubrecord(options)

boolean

Client and server scripts

Returns a value indicating whether the field contains a subrecord.

Record.insertLine(options)

record.Record

Client and server scripts

Inserts a sublist line.

 

 

 

 

Record.removeCurrentSublistSubrecord(options)

record.Record

Client and server scripts

Removes the subrecord for the associated sublist field on the current line.

Record.removeLine(options)

record.Record

Client and server scripts

Removes a sublist line.

Record.removeSublistSubrecord(options)

record.Record

Client and server scripts

Removes the subrecord for the associated sublist field. (standard mode only)

Record.removeSubrecord(options)

record.Record

Client and server scripts

Removes the subrecord for the associated field.

Record.save(options)

number

Client and server scripts

Submits a new record or saves edits to an existing record.

This method is not available to subrecords.

Record.save.promise(options)

number

Client scripts

Submits a new record asynchronously or saves edits to an existing record asynchronously.

This method is not available to subrecords.

Record.selectLine(options)

record.Record

Client and server scripts

Selects an existing line in a sublist.

Record.selectNewLine(options)

record.Record

Client and server scripts

Selects a new line at the end of a sublist.

Record.setCurrentMatrixSublistValue(options)

record.Record

Client and server scripts

Sets the value for the line currently selected in the matrix.

Record.setCurrentSublistText(options)

record.Record

Client and server scripts

Sets the value for the field in the currently selected line by a text representation.

Record.setCurrentSublistValue(options)

record.Record

Client and server scripts

Sets the value for the field in the currently selected line.

Record.setMatrixHeaderValue(options)

record.Record

Client and server scripts

Sets the value for the associated header in the matrix.

Record.setMatrixSublistValue(options)

record.Record

Client and server scripts

Sets the value for the associated field in the matrix.

Record.setSublistText(options)

record.Record

Client and server scripts

Sets the value of a sublist field by a text representation. (standard mode only)

Record.setSublistValue(options)

record.Record

Client and server scripts

Sets the value of a sublist field. (standard mode only)

Record.setText(options)

record.Record

Client and server scripts

Sets the value of the field by a text representation.

Record.setValue(options)

record.Record

Client and server scripts

Sets the value of a field.

Property

Record.id

number (read-only)

Client and server scripts

The internal ID of a specific record.

This property is not available to subrecords.

Record.isDynamic

boolean (read-only)

Client and server scripts

Indicates whether the record is in dynamic or standard mode.

Record.type

string (read-only)

Client and server scripts

The record type.

This property is not available to subrecords.

Sublist Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Sublist.getColumn(options)

record.Column

Client and server scripts

Returns a column in the sublist.

Property

Sublist.id

string (read-only)

Client and server scripts

Returns the internal ID of the sublist.

Sublist.isChanged

boolean (read-only)

Client and server scripts

Indicates whether the sublist has changed on the record form.

Sublist.isDisplay

boolean (read-only)

Client and server scripts

Indicates whether the sublist is displayed on the record form.

Sublist.type

string (read-only)

Client and server scripts

Returns the sublist type.

N/record Default Values

You can specify record initialization parameters that default when creating, copying, loading, and transforming records. To enable this behavior, use the optional defaultValues parameter in the following APIs:

The following table lists initialization types that are available to certain SuiteScript-supported records and the values they can contain.

Record

Initialization Type

Values

All SuiteScript-supported records that support form customization.

customform

<customformid>

Assembly Build

assemblyitem

<assemblyitemid>

Cash Refund

entity

<entityid>

Cash Sale

entity

<entityid>

Charge Rule

entity

<entityid>

Check

entity

<entityid>

Credit Memo

entity

<entityid>

Customer Payment

entity

<entityid>

Customer Refund

entity

<entityid>

Deposit

disablepaymentfilters

<disablepaymentfilters>

Estimate

entity

<entityid>

Expense Report

entity

<entityid>

Invoice

entity

<entityid>

Item Receipt

entity

<entityid>

Non-Inventory Part

subtype

sale | resale | purchase

Opportunity

entity

<entityid>

Other Charge Item

subtype

sale | resale | purchase

Purchase Order

entity

<entityid>

Return Authorization

entity

<entityid>

Sales Order

entity

<entityid>

Script Deployment

script

<scriptid>

Service

subtype

sale | resale | purchase

Subscription Change Order

 

<scriptid>

See Default Values.

Tax Group

nexuscountry

<countrycode>

See Country Codes Used for Initialization Parameters.

Tax Type

country

<countrycode>

See Country Codes Used for Initialization Parameters.

Topic

parenttopic

<parenttopicid>

Vendor Bill

entity

<entityid>

Vendor Payment

entity

<entityid>

Work Order

assemblyitem

<assemblyitemid>

Country Codes Used for Initialization Parameters

If you are scripting the Tax Group or Tax Type records, you can initialize the record to source all values related to a specific country. In your script, use the country code for the countrycodeid value, for example:

          record.create('taxgroup', {nexuscountry: 'AR'}); 

        

Country Code

Country Name

AD

Andorra

AE

United Arab Emirates

AF

Afghanistan

AG

Antigua and Barbuda

AI

Anguilla

AL

Albania

AM

Armenia

AO

Angola

AQ

Antarctica

AR

Argentina

AS

American Samoa

AT

Austria

AU

Australia

AW

Aruba

AX

Åland Islands

AZ

Azerbaijan

BA

Bosnia and Herzegovina

BB

Barbados

BD

Bangladesh

BE

Belgium

BF

Burkina Faso

BG

Bulgaria

BH

Bahrain

BI

Burundi

BJ

Benin

BL

Saint Barthélemy

BM

Bermuda

BN

Brunei Darrussalam

BO

Bolivia (Plurinational State of)

BQ

Bonaire, Sint Eustatius and Saba

BR

Brazil

BS

Bahamas

BT

Bhutan

BV

Bouvet Island

BW

Botswana

BY

Belarus

BZ

Belize

CA

Canada

CC

Cocos (Keeling) Islands

CD

Congo (the Democratic Republic of the)

CF

Central African Republic

CG

Congo

CH

Switzerland

CI

Côte d'Ivoire

CK

Cook Islands

CL

Chile

CM

Cameroon

CN

China

CO

Colombia

CR

Costa Rica

CU

Cuba

CV

Cabo Verde

CW

Curacao

CX

Christmas Island

CY

Cyprus

CZ

Czechia

DE

Germany

DJ

Djibouti

DK

Denmark

DM

Dominica

DO

Dominican Republic

DZ

Algeria

EA

Ceuta and Melilla

EC

Ecuador

EE

Estonia

EG

Egypt

EH

Western Sahara

ER

Eritrea

ES

Spain

ET

Ethiopia

FI

Finland

FJ

Fiji

FK

Falkland Islands (Malvinas)

FM

Micronesia (Federated States of)

FO

Faroe Islands

FR

France

GA

Gabon

GB

United Kingdom

GD

Grenada

GE

Georgia

GF

French Guiana

GG

Guernsey

GH

Ghana

GI

Gibraltar

GL

Greenland

GM

Gambia

GN

Guinea

GP

Guadeloupe

GQ

Equatorial Guinea

GR

Greece

GS

South Georgia and the South Sandwich Islands

GT

Guatemala

GU

Guam

GW

Guinea-Bissau

GY

Guyana

HK

Hong Kong

HM

Heard Island and McDonald Islands

HN

Honduras

HR

Croatia

HT

Haiti

HU

Hungary

IC

Canary Islands

ID

Indonesia

IE

Ireland

IL

Israel

IM

Isle of Man

IN

India

IO

British Indian Ocean Territory

IQ

Iraq

IR

Iran (Islamic Republic of)

IS

Iceland

IT

Italy

JE

Jersey

JM

Jamaica

JO

Jordan

JP

Japan

KE

Kenya

KG

Kyrgyzstan

KH

Cambodia

KI

Kiribati

KM

Comoros

KN

Saint Kitts and Nevis

KP

Korea (the Democratic People's Republic of)

KR

Korea (the Republic of)

KW

Kuwait

KY

Cayman Islands

KZ

Kazakhstan

LA

Lao People's Democratic Republic

LB

Lebanon

LC

Saint Lucia

LI

Liechtenstein

LK

Sri Lanka

LR

Liberia

LS

Lesotho

LT

Lithuania

LU

Luxembourg

LV

Latvia

LY

Libya

MA

Morocco

MC

Monaco

MD

Moldova (the Republic of)

ME

Montenegro

MF

Saint Martin (French part)

MG

Madagascar

MH

Marshall Islands

MK

North Macedonia

ML

Mali

MM

Myanmar

MN

Mongolia

MO

Macao

MP

Northern Mariana Islands

MQ

Martinique

MR

Mauritania

MS

Montserrat

MT

Malta

MU

Mauritius

MV

Maldives

MW

Malawi

MX

Mexico

MY

Malaysia

MZ

Mozambique

NA

Namibia

NC

New Caledonia

NE

Niger

NF

Norfolk Island

NG

Nigeria

NI

Nicaragua

NL

Netherlands

NO

Norway

NP

Nepal

NR

Nauru

NU

Niue

NZ

New Zealand

OM

Oman

PA

Panama

PE

Peru

PF

French Polynesia

PG

Papua New Guinea

PH

Philippines

PK

Pakistan

PL

Poland

PM

Saint Pierre and Miquelon

PN

Pitcairn

PR

Puerto Rico

PS

Palestine, State of

PT

Portugal

PW

Palau

PY

Paraguay

QA

Qatar

RE

Réunion

RO

Romania

RS

Serbia

RU

Russian Federation

RW

Rwanda

SA

Saudi Arabia

SB

Solomon Islands

SC

Seychelles

SD

Sudan

SE

Sweden

SG

Singapore

SH

Saint Helena, Ascension and Tristan da Cunha

SI

Slovenia

SJ

Svalbard and Jan Mayen

SK

Slovakia

SL

Sierra Leone

SM

San Marino

SN

Senegal

SO

Somalia

SR

Suriname

SS

South Sudan

ST

Sao Tome and Principe

SV

El Salvador

SX

Sint Maarten (Dutch part)

SY

Syrian Arab Republic

SZ

Eswatini

TC

Turks and Caicos Islands

TD

Chad

TF

French Southern Territories

TG

Togo

TH

Thailand

TJ

Tajikistan

TK

Tokelau

TM

Turkmenistan

TN

Tunisia

TO

Tonga

TP

Timor-Leste

TR

Türkiye

TT

Trinidad and Tobago

TV

Tuvalu

TW

Taiwan (Province of China)

TZ

Tanzania, the United Republic of

UA

Ukraine

UG

Uganda

UM

United States Minor Outlying Islands

US

United States

UY

Uruguay

UZ

Uzbekistan

VA

Holy See

VC

Saint Vincent and the Grenadines

VE

Venezuela (Bolivarian Republic of)

VG

Virgin Islands (British)

VI

Virgin Islands (U.S.)

VN

Viet Nam

VU

Vanuatu

WF

Wallis and Futuna Islands

WS

Samoa

XK

Kosovo

YE

Yemen

YT

Mayotte

ZA

South Africa

ZM

Zambia

ZW

Zimbabwe

Related Topics

General Notices