N/currentRecord Module Syntax for SuiteScript Client Scripts
Master syntax for N/currentRecord module in SuiteScript client scripts, including retrieval methods and examples.
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.
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category