Get Current Sublist Value in SuiteScript 2.1

Retrieve values from sublist fields using SuiteScript 2.1's currentRecord module. Essential for client scripts.

·2 min read·View Oracle Docs

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:

ParameterTypeRequired/OptionalDescription
options.sublistIdstringRequiredThe internal ID of the sublist. This value can be found in the Records Browser.
options.fieldIdstringRequiredThe 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:

suitescript
1//Add additional code
2...
3var sublistValue = objRecord.getCurrentSublistValue({
4 sublistId: 'item',
5 fieldId: 'item'
6});
7...
8//Add additional code

Make 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 getCurrentSublistValue method allows you to retrieve field values from sublists.
  • Both sublistId and fieldId parameters are mandatory.
  • This method is critical for client-side operations in SuiteScript 2.1 scripts.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Do I need to enable any specific feature flag to use getCurrentSublistValue in SuiteScript 2.1?
No, there are no specific feature flags required to use the getCurrentSublistValue function in SuiteScript 2.1.
What types of values can getCurrentSublistValue return in SuiteScript 2.1?
The getCurrentSublistValue function can return values of types: number, date, string, array, or boolean.
What are the required parameters for using getCurrentSublistValue in a SuiteScript client script?
The required parameters are an options object containing sublistId and fieldId, which represent the internal IDs of the sublist and field, respectively.
What error might be encountered if the sublist is not editable when using getCurrentSublistValue?
If the sublist is not editable, you may encounter the SSS_INVALID_SUBLIST_OPERATION error.
Source: Parameters Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in SuiteScript

View all SuiteScript articles →