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:

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

Note:

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

currentRecord.Column

Object

Client scripts

Encapsulates a column of a sublist on the current record.

currentRecord.CurrentRecord

Object

Client scripts

Represents the record active on the current page.

currentRecord.Field

Object

Client scripts

Represents a body or sublist field.

currentRecord.Sublist

Object

Client scripts

Represents a sublist.

Method

currentRecord.get()

currentRecord.CurrentRecord

Client scripts

Retrieves a record object that represents the current record.

currentRecord.get.promise()

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

Column.id

string (read-only)

Client scripts

Returns the internal ID of the column.

Column.isDisabled

boolean

Client scripts

Indicates whether the column is disabled.

Column.isMandatory

boolean

Client scripts

Indicates whether the column is required.

Column.label

string (read-only)

Client scripts

Returns the UI label for the column.

Column.sublistId

string (read-only)

Client scripts

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

Column.type

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

CurrentRecord.cancelLine(options)

currentRecord.CurrentRecord

Client scripts

Cancels the changes made to the currently selected line.

CurrentRecord.commitLine(options)

currentRecord.CurrentRecord

Client scripts

Commits the currently selected line.

CurrentRecord.findMatrixSublistLineWithValue(options)

number

Client scripts

Returns the line number of the first line that contains the specified value in the matrix column.

CurrentRecord.findSublistLineWithValue(options)

number

Client scripts

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

CurrentRecord.getCurrentMatrixSublistValue(options)

number | Date | string | array | boolean

Client scripts

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

CurrentRecord.getCurrentSublistIndex(options)

number

Client scripts

Gets the line number of the currently selected line.

CurrentRecord.getCurrentSublistSubrecord(options)

currentRecord.CurrentRecord

Client scripts

Gets the subrecord for the associated sublist field on the current line. The subrecord object is retrieved in view mode.

CurrentRecord.getCurrentSublistText(options)

number | Date | string | array | boolean

Client scripts

Gets the value of the field in the currently selected line by text representation.

CurrentRecord.getCurrentSublistValue(options)

number | Date | string | array | boolean

Client scripts

Gets the value of the field in the currently selected line.

CurrentRecord.getField(options)

currentRecord.Field

Client scripts

Gets a field object from the record.

CurrentRecord.getLineCount(options)

number

Client scripts

Returns the number of lines in the sublist.

CurrentRecord.getMatrixHeaderCount(options)

number

Client scripts

Returns the number of columns for the specified matrix.

CurrentRecord.getMatrixHeaderField(options)

currentRecord.Field

Client scripts

Gets the field for the specified header in the matrix.

CurrentRecord.getMatrixHeaderValue(options)

number | Date | string | array | boolean

Client scripts

Gets the value for the associated header in the matrix.

CurrentRecord.getMatrixSublistField(options)

currentRecord.Field

Client scripts

Gets the field for the specified sublist in the matrix.

CurrentRecord.getMatrixSublistValue(options)

number | Date | string | array | boolean

Client scripts

Gets the value for the associated field in the matrix.

CurrentRecord.getSublist(options)

currentRecord.Sublist

Client scripts

Gets the specified sublist object.

CurrentRecord.getSublistField(options)

currentRecord.Field

Client scripts

Gets the specified field object from the sublist.

CurrentRecord.getSublistText(options)

string

Client scripts

Gets the value of the field in a sublist by a string representation.

CurrentRecord.getSublistValue(options)

number | Date | string | array | boolean

Client scripts

Gets the value of the field in a sublist.

CurrentRecord.getSubrecord(options)

currentRecord.CurrentRecord

Client scripts

Gets the subrecord associated with the field. The subrecord object is retrieved in view mode.

CurrentRecord.getText(options)

string

Client scripts

Gets the value of the field by a string representation.

CurrentRecord.getValue(options)

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.

CurrentRecord.hasCurrentSublistSubrecord(options)

boolean

Client scripts

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

CurrentRecord.hasSublistSubrecord(options)

boolean

Client scripts

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

CurrentRecord.hasSubrecord(options)

boolean

Client scripts

Indicates whether the field has a subrecord.

CurrentRecord.insertLine(options)

currentRecord.CurrentRecord

Client scripts

Inserts a new line in a sublist.

 

 

 

 

CurrentRecord.removeCurrentSublistSubrecord(options)

currentRecord.CurrentRecord

Client scripts

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

CurrentRecord.removeLine(options)

currentRecord.CurrentRecord

Client scripts

Removes a line from a sublist.

CurrentRecord.removeSubrecord(options)

currentRecord.CurrentRecord

Client scripts

Removes the subrecord associated with the field.

CurrentRecord.selectLine(options)

void

Client scripts

Selects a line item in a sublist.

CurrentRecord.selectNewLine(options)

currentRecord.CurrentRecord

Client scripts

Selects a new line at the end of the sublist.

CurrentRecord.setCurrentMatrixSublistValue(options)

currentRecord.CurrentRecord

Client scripts

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

CurrentRecord.setCurrentSublistText(options)

currentRecord.CurrentRecord

Client scripts

Sets the value of the field in the currently selected line using a string representation.

CurrentRecord.setCurrentSublistValue(options)

currentRecord.CurrentRecord

Client scripts

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

CurrentRecord.setMatrixHeaderValue(options)

currentRecord.CurrentRecord

Client scripts

Sets the value for the associated header in the matrix.

CurrentRecord.setMatrixSublistValue(options)

currentRecord.CurrentRecord

Client scripts

Sets the value for the associated field in the matrix.

CurrentRecord.setText(options)

currentRecord.CurrentRecord

Client scripts

Sets the value of the field using a string representation.

CurrentRecord.setValue(options)

currentRecord.CurrentRecord

Client scripts

Sets the value of the field.

Property

CurrentRecord.id

number (read-only)

Client scripts

Returns the internal record ID.

CurrentRecord.isDynamic

boolean (read-only)

Client scripts

Indicates whether the record is dynamic.

CurrentRecord.type

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

Field.getSelectOptions(options)

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.

Field.insertSelectOption(options)

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.

Field.removeSelectOption(options)

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

Field.id

string (read-only)

Client scripts

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

Field.isDisabled

boolean

Client scripts

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

Field.isDisplay

boolean

Client scripts

Returns true if the field is set to display on the record form, or false otherwise.

This property is read-only for sublist fields.

Field.isMandatory

boolean

Client scripts

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

Field.isPopup

boolean (read-only)

Client scripts

Returns true if the field is a popup list field, or false otherwise.

Field.isReadOnly

boolean

Client scripts

Returns true if the field on the record form cannot be edited, or false otherwise.

For textarea fields, this property can be read or written to. For all other fields, this property is read-only.

Field.isVisible

boolean (read-only)

Client scripts

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

Field.label

string (read-only)

Client scripts

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

Field.sublistId

string (read-only)

Client scripts

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

Field.type

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

Sublist.getColumn(options)

currentRecord.Column

Client scripts

Returns a column in the sublist.

Property

Sublist.id

string (read-only)

Client scripts

Returns the internal ID of the sublist.

Sublist.isChanged

boolean (read-only)

Client scripts

Indicates whether the sublist has changed on the current record form.

Sublist.isDisplay

boolean (read-only)

Client scripts

Indicates whether the sublist is displayed on the current record form.

Sublist.type

string (read-only)

Client scripts

Returns the sublist type.

Related Topics

General Notices