Get Current Sublist Value in SuiteScript 2.0

Retrieve values from a sublist field in SuiteScript 2.0 using the getCurrentSublistValue method.

·2 min read·View Oracle Docs

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:

ParameterTypeRequired / OptionalDescription
options.sublistIdstringRequiredThe internal ID of the sublist, displayed in the Records Browser.
options.fieldIdstringRequiredThe 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:

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

For a complete script example, refer to the N/currentRecord Module Script Samples.

Related Topics

Key Takeaways:

  • The getCurrentSublistValue method retrieves field values from active sublist lines.
  • It requires parameters specifying the sublistId and fieldId.
  • Common error codes include usage of invalid or missing arguments.

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

Frequently Asked Questions (4)

In which SuiteScript types can the getCurrentSublistValue method be used?
The getCurrentSublistValue method is supported in client scripts.
What parameters are required for using the getCurrentSublistValue method?
The method requires an options object with 'sublistId' and 'fieldId' properties, both of which are strings.
What types of values can the getCurrentSublistValue method return?
The getCurrentSublistValue method can return a number, Date, string, array, or boolean.
What error codes should I be aware of when using getCurrentSublistValue?
Common error codes include SSS_INVALID_SUBLIST_OPERATION and SSS_MISSING_REQD_ARGUMENT, which indicate invalid operations or missing arguments, respectively.
Source: Syntax 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 General

View all General articles →