Get Current Sublist Value in SuiteScript 2.0
Retrieve values from a sublist field in SuiteScript 2.0 using the getCurrentSublistValue method. TL;DR Opening This article covers how to leverage the
TL;DR Opening
This article covers how to leverage the getCurrentSublistValue method in SuiteScript 2.0 to access values from sublist fields effectively. Understanding this method is vital for SuiteScript developers working with dynamic record management.
What is the getCurrentSublistValue Method?
The getCurrentSublistValue method allows you to return the value of a specified field on the currently selected line of a sublist in a record. This is particularly useful in client scripts where user interaction involves sublists, such as items in a sales order.
Method Description
The method returns a value that can be one of several types, including number, Date, string, array, or boolean.
Supported Script Types
- Client scripts
Governance
- None
Module
- N/currentRecord Module
Parameters
The method accepts an options object as a parameter, which contains the following properties:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.sublistId | string | Required | The internal ID of the sublist, displayed in the Records Browser. |
options.fieldId | string | Required | The internal ID of a standard or custom sublist field. |
Error Codes
When using this method, the following errors may occur:
- SSS_INVALID_SUBLIST_OPERATION: This error is thrown if a required argument is invalid or the sublist is not editable.
- SSS_MISSING_REQD_ARGUMENT: This indicates that a required argument is missing or undefined.
Code Sample
Here’s a syntax example of how to use the getCurrentSublistValue method:
1// Add additional code 2...3var sublistValue = objRecord.getCurrentSublistValue({4 sublistId: 'item',5 fieldId: 'item'6});7... 8// Add additional codeFor a complete script example, refer to the N/currentRecord Module Script Samples.
Related Topics
- currentRecord.CurrentRecord
- N/currentRecord Module
- SuiteScript 2.x Modules
Key Takeaways:
- The
getCurrentSublistValuemethod retrieves field values from active sublist lines. - It requires parameters specifying the
sublistIdandfieldId. - Common error codes include usage of invalid or missing arguments.
Frequently Asked Questions (4)
In which SuiteScript types can the getCurrentSublistValue method be used?
What parameters are required for using the getCurrentSublistValue method?
What types of values can the getCurrentSublistValue method return?
What error codes should I be aware of when using getCurrentSublistValue?
Was this article helpful?
More in SuiteScript
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category