Load the 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 How to Find a Record's Internal ID.
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.
N/record Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Client and server scripts |
Encapsulates a column of a sublist on a standard or custom record. |
|
Object |
Client and server scripts |
Encapsulates a body or sublist field on a standard or custom record. |
||
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(). |
|
Object |
Client and server scripts |
Encapsulates a NetSuite record. |
||
Object |
Client and server scripts |
Encapsulates a sublist on a standard or custom record. |
||
Method |
void |
Client and server scripts |
Attaches a record to another record. |
|
Promise |
Client scripts |
Attaches a record asynchronously to another record. |
||
Client and server scripts |
Creates a new record by copying an existing record in NetSuite. |
|||
Promise |
Client scripts |
Creates a new record asynchronously by copying an existing record in NetSuite. |
||
Client and server scripts |
Creates a new record. |
|||
Promise |
Client scripts |
Creates a new record asynchronously. |
||
number |
Client and server scripts |
Deletes a record. |
||
Promise |
Client scripts |
Deletes a record asynchronously. |
||
void |
Client and server scripts |
Detaches a record from another record. |
||
Promise |
Client scripts |
Detaches a record from another record asynchronously. |
||
Object |
Client and server scripts |
Loads an existing record. |
||
Promise |
Client scripts |
Loads an existing record asynchronously. |
||
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. |
||
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. |
||
Client and server scripts |
Transforms a record from one type into another, using data from an existing record. |
|||
Promise |
Client scripts |
Transforms a record from one type into another asynchronously, using data from an existing record. |
||
Enum |
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 |
string (read-only) |
Client and server scripts |
Returns the internal ID of the column. |
|
boolean |
Client and server scripts |
Indicates whether the column is disabled. |
||
boolean |
Client and server scripts |
Indicates whether the column is displayed. |
||
boolean |
Client and server scripts |
Indicates whether the column is required. |
||
boolean (read-only) |
Client and server scripts |
Indicates whether the column is sortable. |
||
string (read-only) |
Client and server scripts |
Returns the UI label for the column. |
||
string (read-only) |
Client and server scripts |
Returns the internal ID of the standard or custom sublist that contains the column. |
||
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 |
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 |
string (read-only) |
Client and server scripts |
Returns the UI label for a standard or custom field body or sublist field. |
|
string (read-only) |
Client and server scripts |
Returns the internal ID of a standard or custom body or sublist field. |
||
string (read-only) |
Client and server scripts |
Returns the type of a body or sublist field. |
||
boolean |
Client and server scripts |
Returns |
||
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. |
||
boolean |
Client and server scripts |
Returns 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 |
Object |
Client and server scripts |
Performs a macro operation and returns its result in an object. |
|
Promise |
Client scripts |
Performs a macro operation asynchronously. |
||
Object |
Client and server scripts |
Performs a macro operation and returns its result in an object. |
||
Promise |
Client scripts |
Performs a macro operation asynchronously. |
||
Property |
string |
Client and server scripts |
The ID of the macro. For a list of macro IDs, see Supported Record Macros |
|
string |
Client and server scripts |
The macro label. |
||
string |
Client and server scripts |
The macro description. |
||
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 |
Client and server scripts |
Cancels the currently selected line on a sublist. |
||
Client and server scripts |
Commits the currently selected line on a sublist. |
|||
Object |
Client and server scripts |
Performs macro operation and returns its result in a plain JavaScript object. |
||
Object |
Client and server scripts |
Provides a plain JavaScript object that contains macro objects defined for a record type, indexed by the Macro ID. |
||
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. |
||
number |
Client and server scripts |
Returns the line number for the first occurrence of a field value in a sublist. |
||
number | Date | string | array | boolean |
Client and server scripts |
Gets the value for the currently selected line in the matrix. |
||
Client and server scripts |
Returns a field object from a sublist. |
|||
number |
Client and server scripts |
Returns the line number of the currently selected line. |
||
Client and server scripts |
Gets the subrecord for the associated sublist field on the current line. |
|||
string |
Client and server scripts |
Returns a text representation of the field value in the currently selected line. |
||
number | Date | string | array | boolean |
Client and server scripts |
Returns the value of a sublist field on the currently selected sublist line. |
||
Client and server scripts |
Returns a field object from a record. |
|||
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. |
||
number |
Client and server scripts |
Returns the number of lines in a sublist. |
||
Client and server scripts |
Provides a macro to execute. |
|||
Object |
Client and server scripts |
Provides a plain JavaScript object that contains macro objects defined for a record type, indexed by the Macro ID. |
||
number |
Client and server scripts |
Returns the number of columns for the specified matrix. |
||
Client and server scripts |
Gets the field for the specified header in the matrix. |
|||
number | Date | string | array | boolean |
Client and server scripts |
Gets the value for the associated header in the matrix. |
||
Client and server scripts |
Gets the field for the specified sublist in the matrix. |
|||
number | Date | string | array | boolean |
Client and server scripts |
Gets the value for the associated field in the matrix. |
||
Client and server scripts |
Returns the specified sublist. |
|||
string[] |
Client and server scripts |
Returns all the names of all the sublists. |
||
Client and server scripts |
Returns a field object from a sublist. |
|||
string[] |
Client and server scripts |
Returns all the field names in a sublist. |
||
Client and server scripts |
Gets the subrecord associated with a sublist field. (standard mode only) |
|||
string |
Client and server scripts |
Returns the value of a sublist field in a text representation. |
||
number | Date | string | array | boolean |
Client and server scripts |
Returns the value of a sublist field. |
||
Client and server scripts |
Gets the subrecord for the associated field. |
|||
string |
Client and server scripts |
Returns the text representation of a field value. |
||
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. |
||
boolean |
Client and server scripts |
Returns a value indicating whether the associated sublist field has a subrecord on the current line. |
||
boolean |
Client and server scripts |
Returns a value indicating whether the associated sublist field contains a subrecord. |
||
boolean |
Client and server scripts |
Returns a value indicating whether the field contains a subrecord. |
||
Client and server scripts |
Inserts a sublist line. |
|||
|
|
|
|
|
Client and server scripts |
Removes the subrecord for the associated sublist field on the current line. |
|||
Client and server scripts |
Removes a sublist line. |
|||
Client and server scripts |
Removes the subrecord for the associated sublist field. (standard mode only) |
|||
Client and server scripts |
Removes the subrecord for the associated field. |
|||
number |
Client and server scripts |
Submits a new record or saves edits to an existing record. This method is not available to subrecords. |
||
number |
Client scripts |
Submits a new record asynchronously or saves edits to an existing record asynchronously. This method is not available to subrecords. |
||
Client and server scripts |
Selects an existing line in a sublist. |
|||
Client and server scripts |
Selects a new line at the end of a sublist. |
|||
Client and server scripts |
Sets the value for the line currently selected in the matrix. |
|||
Client and server scripts |
Sets the value for the field in the currently selected line by a text representation. |
|||
Client and server scripts |
Sets the value for the field in the currently selected line. |
|||
Client and server scripts |
Sets the value for the associated header in the matrix. |
|||
Client and server scripts |
Sets the value for the associated field in the matrix. |
|||
Client and server scripts |
Sets the value of a sublist field by a text representation. (standard mode only) |
|||
Client and server scripts |
Sets the value of a sublist field. (standard mode only) |
|||
Client and server scripts |
Sets the value of the field by a text representation. |
|||
Client and server scripts |
Sets the value of a field. |
|||
Property |
number (read-only) |
Client and server scripts |
The internal ID of a specific record. This property is not available to subrecords. |
|
boolean (read-only) |
Client and server scripts |
Indicates whether the record is in dynamic or standard mode. |
||
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 |
Client and server scripts |
Returns a column in the sublist. |
||
Property |
string (read-only) |
Client and server scripts |
Returns the internal ID of the sublist. |
|
boolean (read-only) |
Client and server scripts |
Indicates whether the sublist has changed on the record form. |
||
boolean (read-only) |
Client and server scripts |
Indicates whether the sublist is displayed on the record form. |
||
string (read-only) |
Client and server scripts |
Returns the sublist type. |
N/record Module Script Samples
The following script samples demonstrate how to use the features of the N/record module.
Create and save a contact record
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
This sample uses SuiteScript 2.1. For more information, see SuiteScript 2.1.
The following sample shows how to use the N/record module to create and save a contact record.
Some of the values in these samples are placeholders. Before using these samples, replace all hard-coded values, such as IDs and file paths, with valid values from your NetSuite account. If you run a script with an invalid value, the system may throw an error.
Create and save a contact record using promise methods
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
This sample uses SuiteScript 2.1. For more information, see SuiteScript 2.1.
The following sample shows how to create and save a contact record using promise methods.
To debug client scripts like the following, you should use Chrome DevTools for Chrome, Firebug debugger for Firefox, or Microsoft Script Debugger for Internet Explorer. For information about these tools, see the documentation provided with each browser. For more information about debugging SuiteScript client scripts, see Debugging Client Scripts.
Access sublists and a subrecord
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following sample shows how to access sublists and a subrecord from a record. This sample requires the Advanced Number Inventory Management feature.
For additional script samples that include subrecords, see SuiteScript 2.x Scripting Subrecords.
Access sublists and a subrecord using promise methods
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following sample shows how to access sublists and a subrecord from a record using promise methods. This sample requires the Advanced Number Inventory Management feature.
To debug client scripts like the following, you should use Chrome DevTools for Chrome, Firebug debugger for Firefox, or Microsoft Script Debugger for Internet Explorer. For information about these tools, see the documentation provided with each browser. For more information about debugging SuiteScript client scripts, see Debugging Client Scripts.
Call a macro on a sales order record
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following sample shows you how to call a calculateTax
macro on a sales order record. To execute a macro on a record, the record must be created or loaded in dynamic mode. Note that the SuiteTax feature must be enabled to successfully execute the macro used in this sample.
For information about record macros, see Overview of Record Action and Macro APIs.
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> |
Tax Type |
country |
<countrycode> |
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:
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 |
Aland 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 |
BQ |
Bonaire, Saint 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, Democratic People's Republic |
CF |
Central African Republic |
CG |
Congo, Republic of |
CH |
Switzerland |
CI |
Cote d'Ivoire |
CK |
Cook Islands |
CL |
Chile |
CM |
Cameroon |
CN |
China |
CO |
Colombia |
CR |
Costa Rica |
CU |
Cuba |
CV |
Cape Verde |
CW |
Curacao |
CX |
Christmas Island |
CY |
Cyprus |
CZ |
Czech Republic |
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 |
FM |
Micronesia, Federal State 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 |
GT |
Guatemala |
GU |
Guam |
GW |
Guinea-Bissau |
GY |
Guyana |
HK |
Hong Kong |
HM |
Heard and McDonald Islands |
HN |
Honduras |
HR |
Croatia/Hrvatska |
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, Democratic People's Republic |
KR |
Korea, 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, Republic of |
ME |
Montenegro |
MF |
Saint Martin |
MG |
Madagascar |
MH |
Marshall Islands |
MK |
Macedonia |
ML |
Mali |
MM |
Myanmar |
MN |
Mongolia |
MO |
Macau |
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 |
St. Pierre and Miquelon |
PN |
Pitcairn Island |
PR |
Puerto Rico |
PS |
State of Palestine |
PT |
Portugal |
PW |
Palau |
PY |
Paraguay |
QA |
Qatar |
RE |
Reunion Island |
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 |
SI |
Slovenia |
SJ |
Svalbard and Jan Mayen Islands |
SK |
Slovak Republic |
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 |
SY |
Syrian Arab Republic |
SZ |
Swaziland |
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 |
East Timor |
TR |
Turkey |
TT |
Trinidad and Tobago |
TV |
Tuvalu |
TW |
Taiwan |
TZ |
Tanzania |
UA |
Ukraine |
UG |
Uganda |
UM |
US Minor Outlying Islands |
US |
United States |
UY |
Uruguay |
UZ |
Uzbekistan |
VA |
Holy See (City Vatican State) |
VC |
Saint Vincent and the Grenadines |
VE |
Venezuela |
VG |
Virgin Islands (British) |
VI |
Virgin Islands (USA) |
VN |
Vietnam |
VU |
Vanuatu |
WF |
Wallis and Futuna Islands |
WS |
Samoa |
XK |
Kosovo |
YE |
Yemen |
YT |
Mayotte |
ZA |
South Africa |
ZM |
Zambia |
ZW |
Zimbabwe |