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.

·2 min read·View Oracle Docs

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:

suitescript
// Add additional code
...
var objRecord = currentRecord.get();
...
// Add additional code

Using 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:

suitescript
1// Add additional code
2...
3function pageInit(context) {
4 var currentRec = context.currentRecord;
5...
6// Add additional code
7}

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?
No, in an entry point client script using the @NScriptType ClientScript annotation, you do not need to explicitly load the current record. You can access it via the context object's currentRecord.
Can modifications be made to a record in view mode using the N/currentRecord module?
No, records are read-only in view mode. Modifications can only be made when the record is in edit mode.
What type of scripts utilize the N/currentRecord module?
The N/currentRecord module is primarily used in client scripts, which execute in the user's browser and can handle events like field changes or form submissions.
How do you retrieve the currentRecord object in a custom module?
In a custom module, you retrieve the currentRecord object by using the currentRecord.get() method to explicitly load the record.
Source: Syntax Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in SuiteScript

View all SuiteScript articles →