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...
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
currentRecordobject without needing explicit loading of theN/currentRecordmodule. To access it, you simply create a variable initialized toscriptContext.currentRecordin your script. -
Client Custom Modules: Unlike entry point scripts, these require you to manually load the
N/currentRecordmodule and retrieve thecurrentRecordobject with methods likecurrentRecord.get()orcurrentRecord.get.promise().
Members of the CurrentRecord Module
Below are the key members of the currentRecord module, categorized as methods and properties:
Methods
| Method | Return Type | Supported Script Types | Description |
|---|---|---|---|
cancelLine(options) | currentRecord.CurrentRecord | Client scripts | Cancels changes to the selected line in the sublist. |
commitLine(options) | currentRecord.CurrentRecord | Client scripts | Commits changes for the selected line. |
getCurrentSublistValue(options) | `number | Date | string |
setValue(options) | currentRecord.CurrentRecord | Client scripts | Sets the value of a specified field. |
getField(options) | currentRecord.Field | Client scripts | Retrieves a field object from the record. |
Properties
| Property | Return Type | Description |
|---|---|---|
id | number (read-only) | Returns the internal record ID. |
type | string (read-only) | Indicates the record type. |
isDynamic | boolean (read-only) | Indicates if the record is dynamic. |
Best Practices for Using the CurrentRecord Module
- Use in Client Scripts: The
currentRecordmodule is designed specifically for client scripts. Use theN/recordmodule 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
currentRecordmodule 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?
What are the supported script types for the commitLine method in the CurrentRecord module?
How can I access the currentRecord object in a client custom module?
Is the dynamic mode property of CurrentRecord always available?
Was this article helpful?
More in Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category