N/currentRecord Module Syntax for SuiteScript Client Scripts
Learn the syntax for using the N/currentRecord module in SuiteScript client scripts, including object retrieval methods and example code.
The N/currentRecord module in SuiteScript allows developers to work with the record currently active on the page. This module is essential for client scripts, enabling real-time interactions with user data in forms.
What is the N/currentRecord Module?
The N/currentRecord module is designed to encapsulate the record that is active in the current client context. It's automatically available to entry point client scripts, which simplifies the process of accessing the current record information.
How to Use the N/currentRecord Module
Object Description
This module allows developers to interact with the records displayed on the user interface, making it integral for client-side scripting tasks such as form validation and dynamic field adjustments.
Supported Script Types
- Client Scripts: These scripts are executed in the user’s browser and can respond to events such as field changes or form submissions.
Methods and Properties
For a detailed look at the properties and methods available with the currentRecord object, refer to the CurrentRecord Object Members documentation.
Syntax Examples
Retrieving the Current Record in a Custom Module
To retrieve the currentRecord object in a custom module where the record is explicitly loaded, use the following syntax:
// Add additional code ...var objRecord = currentRecord.get();...// Add additional codeUsing Current Record in Entry Point Client Scripts
In an entry point client script (those using the @NScriptType ClientScript annotation), you do not need to explicitly load the current record. Here’s an example of how to reference the current record via the context object:
1// Add additional code 2...3function pageInit(context) {4 var currentRec = context.currentRecord;5...6// Add additional code7}Key Considerations
- When working with the current record, be mindful that in view mode, the record is read-only, and modifications will not be accepted until the record is in edit mode.
- Understanding the context manipulation is crucial for effective scripting, especially when handling complex client-side logic.
For a complete practical example of using the currentRecord, check out the N/currentRecord Module Script Samples. This will provide a deeper insight into how to implement this module successfully.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- The N/currentRecord module is essential for client-side record management in SuiteScript.
- You can access the current record dynamically via the context object in entry point client scripts.
- Always be cautious about the editability of records, especially in different modes.
- Refer to related examples for practical implementations to enhance your understanding.
Frequently Asked Questions (4)
Do I need to explicitly load the current record in an entry point client script?
Can modifications be made to a record in view mode using the N/currentRecord module?
What type of scripts utilize the N/currentRecord module?
How do you retrieve the currentRecord object in a custom 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.
