Get Sublist Value in SuiteScript 2.1 for NetSuite
Retrieve sublist line item values using SuiteScript 2.1, essential for server-side scripting in NetSuite.
The getSublistValue method in SuiteScript 2.x allows developers to retrieve the value of specific line items from sublists within records. This functionality is crucial for server-side scripts that need to access and manipulate data dynamically. The method is supported exclusively by server scripts and offers a straightforward way to interact with sublist data.
Method Description
The getSublistValue method fetches the value of a specified line item from a designated sublist. This is particularly useful when you need to read data in the context of a transaction, where multiple line items exist.
Returns
- Type:
string
This method returns the value of the specified sublist line item as a string.
Supported Script Types
- Server scripts
Governance
- None
Module
- N/http Module
Parent Object
The parent object associated with this method is the http.ServerRequest.
Parameters
The options parameter is defined as a JavaScript object containing the following fields:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.group | string | required | The internal ID of the sublist. |
options.line | string | required | The line number in the sublist, starting at 0. |
options.name | string | required | The line item ID of the field. |
Errors
| Error Code | Message | Thrown If |
|---|---|---|
SSS_MISSING_REQD_ARGUMENT | Missing a required argument: {param name} | When options.group or options.line is not specified. |
Syntax Example
To utilize the getSublistValue method, consider the following code sample:
1// Add additional code 2...3serverRequest.getSublistValue({4 group: 'item',5 name: 'amount',6 line: '2'7});8...9// Add additional codeThis example demonstrates how to retrieve the value of the field amount from the third line of the item sublist, illustrating the simplicity and effectiveness of this method.
Related Topics
- http.ServerRequest
- N/http Module
- SuiteScript 2.x Modules
Note: For more comprehensive scripting examples, refer to the relevant sections in the SuiteScript documentation.
Key Takeaways:
- Use
getSublistValueto access sublist line item values. - This method requires a JavaScript object with specific parameters.
- Appropriate error handling is essential for required parameters.
Frequently Asked Questions (4)
Does the getSublistValue method apply to both client and server scripts?
What are the required parameters for the getSublistValue method?
What error occurs if a required parameter is omitted when using getSublistValue?
How does the getSublistValue method handle line numbers?
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.
