N/currentRecord Module: Accessing Active Records in SuiteScript
The N/currentRecord module allows SuiteScript developers to access and manipulate the currently active record in client scripts.
The N/currentRecord module is essential in SuiteScript for accessing the record that is currently active in the client context. It operates in a dynamic manner, meaning it mimics the behavior of the record as displayed in the NetSuite UI. Understanding how this module works is crucial for developers wanting to create effective client-side scripts.
How Does the N/currentRecord Module Work?
The N/currentRecord module is always a dynamic object, ensuring that changes made in scripts reflect immediately within the user interface, as opposed to deferring until the record is saved. Importantly, when a record is in view mode, it becomes read-only, and developers should ensure they do not attempt to edit it using set APIs during this time.
Script Types That Use N/currentRecord
The N/currentRecord module can be utilized in various types of scripts:
- Entry Point Client Scripts: These scripts are designated with the
@NScriptType ClientScriptannotation. They are automatically provided with acurrentRecord.CurrentRecordobject, allowing easy access to the currently active record without requiring a manual load of the N/currentRecord module. - Client Custom Modules: Unlike entry point scripts, these may not have an
@NScriptTypeannotation. In this case, developers need to manually load the module while defining it in the script's define statement. Here, retrieving thecurrentRecordobject requires using methods likecurrentRecord.get()orcurrentRecord.get.promise().
Usage of N/currentRecord vs. N/record
While both N/currentRecord and N/record modules provide access to body fields and sublist items, they serve slightly different purposes:
- N/currentRecord: Best suited for client scripts that require interaction with the currently active record.
- N/record: Recommended for server scripts or when interacting with records other than the currently active one.
Key Functionality and Methods
Understanding the available methods and member objects within the N/currentRecord module is essential:
Member Types:
| Member Type | Name | Description |
|---|---|---|
| Object | currentRecord.Column | Encapsulates a column of a sublist. |
| Object | currentRecord.CurrentRecord | Represents the active record on the current page. |
| Object | currentRecord.Field | Represents a body or sublist field. |
| Object | currentRecord.Sublist | Represents a sublist. |
| Method | currentRecord.get() | Retrieves the current record object. |
| Method | currentRecord.get.promise() | Retrieves a promise for the current record object. |
Conclusion
The N/currentRecord module is crucial for any SuiteScript developer working on client scripts that interact with records. Proper understanding and implementation of this module can greatly enhance the functionality and efficiency of client-side scripts.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- The N/currentRecord module facilitates access to the currently active record in client scripts.
- This module operates dynamically, mirroring UI behaviors.
- Use it in entry point client scripts without explicit loading; manual loading is required for custom modules.
- The N/currentRecord is preferred for client interactions, while N/record serves server-side needs.
Frequently Asked Questions (4)
How does the N/currentRecord module handle record changes dynamically?
Can the N/currentRecord module be used in scripts other than entry point client scripts?
What happens if you try to edit a read-only record using the N/currentRecord module?
What methods are available for retrieving the current record object with the N/currentRecord module?
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.
