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.
Use Record.setValue(options) to set a body field on a NetSuite record. It is available to client and server scripts in standard and dynamic modes and has no governance-unit charge of its own.
Use the options object
// Call pattern: recordObject, fieldId and fieldValue must already be defined.recordObject.setValue({ fieldId, value: fieldValue});The example is an API call pattern, not a complete script or an account-specific field configuration. A successful setter call is not proof that a server-side record has been saved.
Match the field's expected type
Use the internal field ID and a value appropriate to the field: for example, a boolean for a checkbox and a Date object for a date field. Check the API and field definition rather than assuming that a displayed text label is the correct stored value.
The optional ignoreFieldChange: true suppresses the field-change and secondary event described by the API. Its default is false.
Troubleshoot deliberately
INVALID_FLD_VALUE points to an incompatible value type. SSS_MISSING_REQD_ARGUMENT means a required argument is absent. First inspect the field ID, actual JavaScript value and script context; avoid hiding the error with a catch that discards it.
Sources: Oracle's Record.setValue reference and Finding Internal IDs of Record Fields.
For line fields, use the standard/dynamic sublist guide. The call pattern above has not been executed in a NetSuite account.
Frequently Asked Questions (4)
Does Record.setValue support client and server scripts?
How do I suppress its field-change event?
What does INVALID_FLD_VALUE indicate?
Does one value type work for every 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.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.
- 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.
- Enhancements to SuiteScript User Role Context Clarification
SuiteScript updates clarify the user and role contexts for script executions, improving deployment understanding and management.
