CurrentRecord Object Members in SuiteScript 2.1 Reference

The CurrentRecord object in SuiteScript 2.1 provides methods to access and manipulate the active record in the client context, enhancing user...

·3 min read·View Oracle Docs

The CurrentRecord object is crucial for SuiteScript developers as it allows access to the active record in the current client context. This dynamic object operates in real-time and is essential for client-side scripting.

How Does the CurrentRecord Module Work?

The N/currentRecord module is utilized in various client scripts to interact with the record currently active on the user's interface. It's important to note that while in view mode, the current record becomes read-only, and any set APIs will not function.

You can access the currentRecord module in two types of scripts:

  • Entry Point Client Scripts: These scripts automatically receive a currentRecord object without needing explicit loading of the N/currentRecord module. To access it, you simply create a variable initialized to scriptContext.currentRecord in your script.

  • Client Custom Modules: Unlike entry point scripts, these require you to manually load the N/currentRecord module and retrieve the currentRecord object with methods like currentRecord.get() or currentRecord.get.promise().

Members of the CurrentRecord Module

Below are the key members of the currentRecord module, categorized as methods and properties:

Methods

MethodReturn TypeSupported Script TypesDescription
cancelLine(options)currentRecord.CurrentRecordClient scriptsCancels changes to the selected line in the sublist.
commitLine(options)currentRecord.CurrentRecordClient scriptsCommits changes for the selected line.
getCurrentSublistValue(options)`numberDatestring
setValue(options)currentRecord.CurrentRecordClient scriptsSets the value of a specified field.
getField(options)currentRecord.FieldClient scriptsRetrieves a field object from the record.

Properties

PropertyReturn TypeDescription
idnumber (read-only)Returns the internal record ID.
typestring (read-only)Indicates the record type.
isDynamicboolean (read-only)Indicates if the record is dynamic.

Best Practices for Using the CurrentRecord Module

  • Use in Client Scripts: The currentRecord module is designed specifically for client scripts. Use the N/record module for server-side scripts or if you need to manipulate other records.
  • Handle Read-Only Mode Carefully: When the current record is viewed in read-only mode, ensure your script accounts for this to avoid errors.
  • Dynamic Mode Awareness: Familiarize yourself with dynamic scripting behaviors to properly sequence setting field values, as these can affect how values are processed in real-time.

Who This Affects

  • Developers: Those implementing or maintaining SuiteScript client scripts.
  • Administrators: Professionals configuring SuiteScript for business processes.

Key Takeaways

  • The currentRecord module is vital for managing the active record in client scripts.
  • Always consider the mode (view/edit) for effective script execution.
  • Utilize the appropriate methods and properties to interact with record data efficiently.

Frequently Asked Questions (4)

Does the CurrentRecord object allow modifications when the record is in view mode?
No, when the record is in view mode, it becomes read-only, and set APIs will not function.
What are the supported script types for the commitLine method in the CurrentRecord module?
The commitLine method is supported in client scripts.
How can I access the currentRecord object in a client custom module?
In a client custom module, you need to manually load the N/currentRecord module and retrieve the currentRecord object using methods like currentRecord.get() or currentRecord.get.promise().
Is the dynamic mode property of CurrentRecord always available?
Yes, the isDynamic property is a read-only indicator available on the CurrentRecord object, showing if the record is dynamic.
Source: CurrentRecord 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 Platform

View all Platform articles →