SuiteScript 2.x Sublist Values: Standard and Dynamic Mode

Use setSublistValue in standard mode; select a line, set its current value and commit it in dynamic mode. Choose the API from the record's mode.

·1 min read·436 views·View Oracle Docs

Choose the API from the record's mode. Record.setSublistValue(options) is for standard mode. For dynamic records, work with the selected line instead.

Standard mode

Pass the internal sublist ID, internal field ID, zero-based line index and correctly typed value:

javascript
1// Call pattern: recordObject and these variables must already be defined.
2recordObject.setSublistValue({
3 sublistId,
4 fieldId,
5 line: lineIndex,
6 value: fieldValue
7});

This is an illustrative call pattern, not a deployable script. Resolve the actual IDs and expected value type for your record before using it.

Dynamic mode

Use the selected-line sequence:

javascript
// Call pattern for an existing dynamic record and an existing editable line.
recordObject.selectLine({ sublistId, line: lineIndex });
recordObject.setCurrentSublistValue({ fieldId, sublistId, value: fieldValue });
recordObject.commitLine({ sublistId });

Dynamic sourcing and validation happen as fields are edited, so field order can matter. Standard mode defers much record processing until save, but that does not mean an invalid sublist edit cannot fail immediately: editing a line triggers internal line validation.

Diagnose a failed edit

Check the record mode, IDs, line index, editability and value type before changing the code. Oracle lists INVALID_FLD_VALUE, SSS_INVALID_SUBLIST_OPERATION and SSS_MISSING_REQD_ARGUMENT for setSublistValue.

Sources: setSublistValue, standard and dynamic modes, setCurrentSublistValue, and commitLine.

For body fields, see Record.setValue. These call patterns have not been executed in a NetSuite account.

Frequently Asked Questions (4)

Can I use Record.setSublistValue in dynamic mode?
No. Use selectLine, setCurrentSublistValue and commitLine for an existing dynamic line.
Does the line index begin at zero?
Yes. SuiteScript 2.x sublist line indexing begins at zero.
Does standard mode postpone all sublist validation until save?
No. An edit triggers internal line validation and can fail immediately.
Can I pass any value type to a sublist field?
No. The supplied value must match the target field type and the specific field restrictions.
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 SuiteScript

View all SuiteScript articles →