Get Current Sublist Value in SuiteScript 2.1
Retrieve values from sublist fields using SuiteScript 2.1's currentRecord module. Essential for client scripts.
TL;DR
You can obtain the value of a specific sublist field on the currently selected sublist line using the currentRecord module in SuiteScript 2.1. This is particularly useful for client scripts that need to interact with sublists on forms.
Method Description
The getCurrentSublistValue function returns the value of a given sublist field on the active line of a specified sublist. The value returned could be of types: number, date, string, array, or boolean.
Supported Script Types
- Client scripts
Governance
No governance limitations apply to this operation.
Parameters
The options parameter for this function is a JavaScript object that requires specific attributes:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.sublistId | string | Required | The internal ID of the sublist. This value can be found in the Records Browser. |
options.fieldId | string | Required | The internal ID of the sublist field, which can be standard or custom. |
Errors
When using this method, the following errors may occur:
SSS_INVALID_SUBLIST_OPERATION: Triggered if a required argument is invalid or if the sublist is not editable.SSS_MISSING_REQD_ARGUMENT: Occurs when any required argument is missing or undefined.
Syntax
Here is how to correctly implement the getCurrentSublistValue in your SuiteScript:
1//Add additional code 2...3var sublistValue = objRecord.getCurrentSublistValue({4 sublistId: 'item',5 fieldId: 'item'6});7...8//Add additional codeMake sure to replace 'item' with your actual sublist and field IDs as necessary.
Who This Affects
- Developers: Those writing client scripts that need to interact with sublists on customer forms.
- Administrators: Users managing SuiteScript within their NetSuite environment.
Key Takeaways
- The
getCurrentSublistValuemethod allows you to retrieve field values from sublists. - Both
sublistIdandfieldIdparameters are mandatory. - This method is critical for client-side operations in SuiteScript 2.1 scripts.
Frequently Asked Questions (4)
Do I need to enable any specific feature flag to use getCurrentSublistValue in SuiteScript 2.1?
What types of values can getCurrentSublistValue return in SuiteScript 2.1?
What are the required parameters for using getCurrentSublistValue in a SuiteScript client script?
What error might be encountered if the sublist is not editable 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