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.
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:
1// Call pattern: recordObject and these variables must already be defined.2recordObject.setSublistValue({3 sublistId,4 fieldId,5 line: lineIndex,6 value: fieldValue7});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:
// 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?
Does the line index begin at zero?
Does standard mode postpone all sublist validation until save?
Can I pass any value type to a sublist field?
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.
- 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.
- SuiteScript Record.setValue: Body Fields, Types and Errors
Set NetSuite body fields with Record.setValue, matching field IDs and value types and checking common API errors.
- Enhancements to SuiteScript User Role Context Clarification
SuiteScript updates clarify the user and role contexts for script executions, improving deployment understanding and management.
