N/currentRecord Module Members for SuiteScript Client Scripts

Utilize the N/currentRecord module to handle current records in SuiteScript client scripts effectively.

·3 min read·View Oracle Docs

The N/currentRecord module allows SuiteScript developers to access and manipulate the active record within the current client context. This module operates using a dynamic object model, which means that any interactions with the current record reflect real-time changes. It's important to note that when the current record is in view mode, it is read-only, limiting any direct edits using set APIs.

Script Usage

The N/currentRecord module can be employed in various types of scripts:

  • Entry Point Client Scripts: These scripts automatically receive a currentRecord.CurrentRecord object that abstracts the current record. To use it, define a variable and set it to scriptContext.currentRecord, which is available in all SuiteScript 2.x Client Script entry points.
  • Client Custom Modules: For these, you must manually load the module in the script's define statement and retrieve a record object using currentRecord.get() or currentRecord.get.promise() methods.

Key Differences Between N/currentRecord and N/record Modules

While both modules allow access to body and sublist fields, N/currentRecord should primarily be used in client scripts targeting the currently active record. The N/record module is more appropriate for server-side scripts that interact with records not currently active.

Additionally, N/currentRecord restricts editing of subrecords when in view mode, though these subrecords can still be retrieved. For greater complexity or when working with multiple records, developers should prefer the N/record module.

N/currentRecord Module Members

Below is a summary of the members available in the N/currentRecord module:

Member TypeNameReturn Type / Value TypeSupported Script TypesDescription
ObjectcurrentRecord.ColumnObjectClient scriptsEncapsulates a column of a sublist on the current record.
ObjectcurrentRecord.CurrentRecordObjectClient scriptsRepresents the record active on the current page.
ObjectcurrentRecord.FieldObjectClient scriptsRepresents a body or sublist field.
ObjectcurrentRecord.SublistObjectClient scriptsRepresents a sublist.
MethodcurrentRecord.get()currentRecord.CurrentRecordClient scriptsRetrieves a record object that represents the current record.
MethodcurrentRecord.get.promise()PromiseClient scriptsRetrieves a promise for an object that represents the current record.

Additional Information

When using the currentRecord capabilities, keep in mind the various properties and methods that allow interaction with sublists, fields, and line items. This flexibility is crucial for creating responsive and dynamic user experiences in your SuiteScript applications.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • Use the N/currentRecord module for real-time access to the current record in SuiteScript client scripts.
  • Understand the differences between N/currentRecord and N/record modules to choose the appropriate one for your needs.
  • Leverage the various methods available in the currentRecord module for effective record manipulation.

Frequently Asked Questions (4)

How can I retrieve a record object in a Client Custom Module using the N/currentRecord module?
In a Client Custom Module, you must manually load the N/currentRecord module in the script's define statement and use the `currentRecord.get()` or `currentRecord.get.promise()` methods to retrieve a current record object.
Can I edit body fields of the current record when it is in view mode using the N/currentRecord module?
No, when the current record is in view mode, it is read-only, which limits any direct edits using set APIs with the N/currentRecord module.
What is the primary use case for the N/currentRecord module in SuiteScript?
The N/currentRecord module is primarily used in client scripts to access and manipulate the currently active record within the client context.
When should I use the N/record module instead of the N/currentRecord module?
You should use the N/record module for server-side scripts that interact with records not currently active, especially in complex scenarios or when working with multiple records.
Source: Sublist Object Members 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 →