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.

·1 min read·211 views·View Oracle Docs

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

javascript
// 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?
Yes. Oracle documents both client and server script support.
How do I suppress its field-change event?
Set the optional ignoreFieldChange property to true; check the API documentation for the affected events.
What does INVALID_FLD_VALUE indicate?
The value type does not match the field type.
Does one value type work for every field?
No. Use the type required by the target field, such as a boolean for a checkbox or a Date for a date field.
Source: Errors — 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 →