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.
Source: This article is based on Oracle's official NetSuite documentation.
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 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