N/currentRecord Module Members for SuiteScript Development
The N/currentRecord module in SuiteScript provides methods and properties for accessing and manipulating the current record in client scripts.
TL;DR Opening
The N/currentRecord module is essential for SuiteScript developers, enabling access to the currently active record within client scripts. This module provides a dynamic way to manipulate record data in real-time, enhancing user experience.
Overview of N/currentRecord Module
The N/currentRecord module allows developers to access the active record in the current client context. This module operates in dynamic mode, meaning that any changes made to the record are reflected in real-time within the NetSuite user interface. However, it is important to note that when a record is in view mode, it becomes read-only, and any attempt to edit it using set APIs will fail.
Script Types Supporting N/currentRecord
You can use the N/currentRecord module in various script types:
- Entry Point Client Scripts: These scripts automatically have access to the currentRecord object via the
scriptContext.currentRecordproperty. Developers do not need to explicitly load the N/currentRecord module. - Client Custom Modules: For scripts lacking an
@NScriptTypeannotation, the N/currentRecord module must be manually loaded in the define statement, and the currentRecord object must be explicitly retrieved usingcurrentRecord.get()orcurrentRecord.get.promise().
Accessing Record Fields
Similar to the N/record module, the N/currentRecord module grants access to body and sublist fields. However, the N/currentRecord module is specifically designed for client scripts that need to manipulate the currently active record, while the N/record module is used for server scripts and when dealing with non-active records.
Member Types in N/currentRecord
The following table summarizes the members of the N/currentRecord module:
| Member Name | Type | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
currentRecord.Column | Object | - | Client scripts | Represents a column in 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 on the current record. |
currentRecord.get() | Method | currentRecord.CurrentRecord | Client scripts | Retrieves a record object representing the current record. |
currentRecord.get.promise() | Method | Promise | Client scripts | Retrieves a promise for an object representing the current record. |
Field Object Members
The Field object within the currentRecord module contains specific methods:
| Member Name | Type | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
Field.getSelectOptions(options) | Method | array | Client scripts | Returns an array of available options for select fields. |
Field.insertSelectOption(options) | Method | void | Client scripts | Inserts an option into certain types of select fields. |
Field.removeSelectOption(options) | Method | void | Client scripts | Removes an option from certain types of select fields. |
Field.id | Property | string | Client scripts | Returns the internal ID of the field. |
Field.isDisabled | Property | boolean | Client scripts | Indicates if the field is disabled on the record form. |
Field.label | Property | string | Client scripts | Returns the UI label for the field. |
Best Practices
- Always ensure the current record is not in view mode when attempting to modify field values.
- Utilize the currentRecord module's methods to interact efficiently with active records and sublists in your client scripts.
- When working with select fields, remember that you can only manipulate options on fields that were initialized from Suitelets or beforeLoad scripts.
Who This Affects
- Developers: Those creating client scripts in SuiteScript will directly benefit from using the N/currentRecord module.
Key Takeaways
- The N/currentRecord module is crucial for dynamic record manipulation in client scripts.
- It offers unique methods and properties for accessing the active record's fields and sublists.
- Understanding working modes (dynamic vs. view) is essential to effectively utilize this module.
Frequently Asked Questions (4)
How can I access the N/currentRecord module in a client custom module?
Can the N/currentRecord module be used in server-side scripts?
What happens if I try to edit a record in view mode using the N/currentRecord module?
Which method would I use to retrieve a promise for the current record in a client script?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Custom Tool Script Enhancements in NetSuite
Custom tool scripts in NetSuite gain execution log support and a new management page in February 16, 2026.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
