N/currentRecord Module
Use the N/currentRecord module to access the record that is active in the current client context. This module is always a dynamic object and mode of work is always dynamic, not deferred dynamic/standard. For more information, see SuiteScript 2.x Standard and Dynamic Modes. Be aware that when the current record is in view mode it cannot be edited; it is a read-only record when in view mode. As such, any set APIs do not work on the current record in view mode.
You can use the currentRecord module in the following types of scripts:
-
Entry point client scripts — These scripts use the
@NScriptType ClientScript
annotation. (For details, see SuiteScript 2.x JSDoc Validation.) The system automatically provides this type of script with a currentRecord.CurrentRecord object that represents the current record. For this reason, an entry point client script does not have to explicitly load the N/currentRecord module. To access the currentRecord object, create a variable and initialize it to the value of thescriptContext.currentRecord
property, which is available in each of the SuiteScript 2.x Client Script Entry Points and API. For an example, see SuiteScript Client Script Sample. -
Client custom modules — These scripts do not use an
@NScriptType
annotation (see SuiteScript 2.x Custom Modules). For these scripts, you must manually load the N/currentRecord module by naming it in the script’s define statement. Additionally, you must actively retrieve a currentRecord.CurrentRecord object by using the currentRecord.get() or currentRecord.get.promise() method. For an example, see N/currentRecord Module Script Samples.
Like the N/record Module, the currentRecord module provides access to body and sublist fields. However, you should use the record module for server scripts and for cases where a client script needs to interact with a record other than the currently active record. You should use the currentRecord module for client scripts that need to interact with the currently active record.
Additionally, the functionality of the two modules varies slightly. For example, the currentRecord module does not permit the editing of subrecords, although subrecords can be retrieved in view mode. For additional details, see the following topics:
In This Help Topic
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 interacting with an instance of a custom record type, see Custom Record.
N/currentRecord Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Client scripts |
Encapsulates a column of a sublist on the current record. |
|
Object |
Client scripts |
Represents the record active on the current page. |
||
Object |
Client scripts |
Represents a body or sublist field. |
||
Object |
Client scripts |
Represents a sublist. |
||
Method |
Client scripts |
Retrieves a record object that represents the current record. |
||
Promise |
Client scripts |
Retrieves a promise for an object that represents the current record. |
Column Object Members
The following members are called on the currentRecord.Column object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string (read-only) |
Client scripts |
Returns the internal ID of the column. |
|
boolean |
Client scripts |
Indicates whether the column is disabled. |
||
boolean |
Client scripts |
Indicates whether the column is required. |
||
string (read-only) |
Client scripts |
Returns the UI label for the column. |
||
string (read-only) |
Client scripts |
Returns the internal ID of the standard or custom sublist that contains the column. |
||
string (read-only) |
Client scripts |
Returns the column type. |
CurrentRecord Object Members
The following members are called on the currentRecord.CurrentRecord object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Client scripts |
Cancels the changes made to the currently selected line. |
||
Client scripts |
Commits the currently selected line. |
|||
number |
Client scripts |
Returns the line number of the first line that contains the specified value in the matrix column. |
||
number |
Client scripts |
Gets the line number for the first occurrence of a field value in a sublist. |
||
number | Date | string | array | boolean |
Client scripts |
Gets the value for the currently selected line in the matrix. |
||
number |
Client scripts |
Gets the line number of the currently selected line. |
||
Client scripts |
Gets the subrecord for the associated sublist field on the current line. The subrecord object is retrieved in view mode. |
|||
number | Date | string | array | boolean |
Client scripts |
Gets the value of the field in the currently selected line by text representation. |
||
number | Date | string | array | boolean |
Client scripts |
Gets the value of the field in the currently selected line. |
||
Client scripts |
Gets a field object from the record. |
|||
number |
Client scripts |
Returns the number of lines in the sublist. |
||
number |
Client scripts |
Returns the number of columns for the specified matrix. |
||
Client scripts |
Gets the field for the specified header in the matrix. |
|||
number | Date | string | array | boolean |
Client scripts |
Gets the value for the associated header in the matrix. |
||
Client scripts |
Gets the field for the specified sublist in the matrix. |
|||
number | Date | string | array | boolean |
Client scripts |
Gets the value for the associated field in the matrix. |
||
Client scripts |
Gets the specified sublist object. |
|||
Client scripts |
Gets the specified field object from the sublist. |
|||
string |
Client scripts |
Gets the value of the field in a sublist by a string representation. |
||
number | Date | string | array | boolean |
Client scripts |
Gets the value of the field in a sublist. |
||
Client scripts |
Gets the subrecord associated with the field. The subrecord object is retrieved in view mode. |
|||
string |
Client scripts |
Gets the value of the field by a string representation. |
||
number | Date | string | array | boolean |
Client scripts |
Gets the value of the field. Not to be used on custom password fields. Use crypto.checkPasswordField(options) instead. |
||
boolean |
Client scripts |
Returns a value indicating whether the associated sublist field has a subrecord on the current line. |
||
boolean |
Client scripts |
Returns a value indicating whether the associated sublist field contains a subrecord. |
||
boolean |
Client scripts |
Indicates whether the field has a subrecord. |
||
Client scripts |
Inserts a new line in a sublist. |
|||
|
|
|
|
|
Client scripts |
Removes the subrecord for the associated sublist field on the current line. |
|||
Client scripts |
Removes a line from a sublist. |
|||
Client scripts |
Removes the subrecord associated with the field. |
|||
void |
Client scripts |
Selects a line item in a sublist. |
||
Client scripts |
Selects a new line at the end of the sublist. |
|||
Client scripts |
Sets the value for the currently selected line in the matrix. |
|||
Client scripts |
Sets the value of the field in the currently selected line using a string representation. |
|||
Client scripts |
Sets the value of the field in the currently selected line. |
|||
Client scripts |
Sets the value for the associated header in the matrix. |
|||
Client scripts |
Sets the value for the associated field in the matrix. |
|||
Client scripts |
Sets the value of the field using a string representation. |
|||
Client scripts |
Sets the value of the field. |
|||
Property |
number (read-only) |
Client scripts |
Returns the internal record ID. |
|
boolean (read-only) |
Client scripts |
Indicates whether the record is dynamic. |
||
string (read-only) |
Client scripts |
Returns the record type. |
Field Object Members
The following members are called on the currentRecord.Field object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
array |
Client 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. |
|
void |
Client scripts |
Inserts an option into certain types of select and multiselect fields. This method is usable only in fields that were added by a front-end Suitelet or beforeLoad user event script. |
||
void |
Client scripts |
Removes an option from certain types of select and multiselect fields. This method is usable only in fields that were added by a front-end Suitelet or beforeLoad user event script. It is supported only in client scripts. |
||
Object |
string (read-only) |
Client scripts |
Returns the internal ID of a standard or custom body or sublist field. |
|
boolean |
Client scripts |
Returns |
||
boolean |
Client scripts |
Returns This property is read-only for sublist fields. |
||
boolean |
Client scripts |
Returns |
||
boolean (read-only) |
Client scripts |
Returns |
||
boolean |
Client scripts |
Returns For textarea fields, this property can be read or written to. For all other fields, this property is read-only. |
||
boolean (read-only) |
Client scripts |
Returns |
||
string (read-only) |
Client scripts |
Returns the UI label for a standard or custom field body or sublist field. |
||
string (read-only) |
Client scripts |
Returns the ID of the sublist associated with the specified sublist field. |
||
string (read-only) |
Client scripts |
Returns the type of a body or sublist field. |
Sublist Object Members
The following members are called on the currentRecord.Sublist object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Client scripts |
Returns a column in the sublist. |
||
Property |
string (read-only) |
Client scripts |
Returns the internal ID of the sublist. |
|
boolean (read-only) |
Client scripts |
Indicates whether the sublist has changed on the current record form. |
||
boolean (read-only) |
Client scripts |
Indicates whether the sublist is displayed on the current record form. |
||
string (read-only) |
Client scripts |
Returns the sublist type. |