N/recordContext Module Members
Explore N/recordContext module members, including methods and their types for SuiteScript development.
The N/recordContext module provides developers with critical functionality to work with record contexts in SuiteScript. This module includes various members that offer insights and methods pertaining to the context within which records are processed.
What are the Members of the N/recordContext Module?
The N/recordContext module consists of the following key members:
| Member Name | Type | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|---|
recordContext.RecordContext | Object | Object (read-only) | Client and server scripts | Contains key-value pairs that represent context types and their values. |
recordContext.getContext(options) | Method | recordContext.RecordContext | Client and server scripts | Returns the record context object for a record. |
recordContext.ContextType | Enum | enum (read-only) | Client and server scripts | Holds values for the context type, used in contextTypes for the getContext method. |
Understanding the getContext Method
The recordContext.getContext(options) method is pivotal for accessing the context of records, particularly depending on whether the record is currently loaded in your script.
-
For Unloaded Records: When a record is not yet loaded, the record is specified through the
recordTypeandrecordIdparameters:javascriptrecordContext.getContext({recordType: 'customer',recordId: '123'}); -
For Loaded Records: If the record is already loaded in your script, use the
recordparameter:javascriptrecordContext.getContext({record: customerRecord});
Parameters of the getContext Method
The options parameter is a JavaScript object that consists of several keys:
recordType: string, required if the record is not loaded in your script.recordId: string, required if the record is not loaded in your script.record: record.Record, required if the record is loaded in your script.contextTypes: Array<string>, optional, specifies the types of contexts to retrieve.
Common Errors
The method may throw various errors based on the parameters provided:
MUTUALY_EXCLUSIVE_ARGUMENT: Thrown if both a loaded record and a record ID/record type are provided.MISSING_REQD_ARGUMENT: Triggered when a required parameter is missing.SSS_INVALID_TYPE_ARG: Indicates a wrong parameter type was provided.UNKNOWN_CONTEXT_TYPE: Occurs if an invalid context type is given.
By understanding these module members and their appropriate usage, developers can effectively manage record context in their SuiteScript applications.
Key Takeaways
- The N/recordContext module is essential for accessing record contexts in SuiteScript.
- The
getContextmethod can retrieve contexts for both loaded and unloaded records. - Proper use of parameters is critical to preventing errors during context retrieval.
Frequently Asked Questions (4)
Can the `recordContext.getContext` method be used in both client and server scripts?
What happens if both a loaded record and a record ID/record type are provided when using the `getContext` method?
What should I provide as parameters when retrieving the context for an unloaded record in SuiteScript?
Is the `contextTypes` parameter mandatory when using the `getContext` method?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
