Error Handling and Update Method in SuiteScript

Learn error handling and methods for updating records in SuiteScript, optimally managing field submissions.

·3 min read·View Oracle Docs

TL;DR Opening: This article discusses how to handle errors when updating records in SuiteScript. It outlines the capabilities of the update methods and the parameters required to execute updates efficiently.

What Does the Update Method Do?

The update method in SuiteScript is designed to allow developers to modify one or more body fields on existing records without needing to load the parent record. This feature enhances efficiency, particularly when dealing with multiple field updates.

What Fields Can Be Updated?

You can edit and submit several types of fields using this method:

  • Standard body fields that support inline editing
  • Custom body fields that support inline editing
  • Select and multi-select fields

However, there are limitations on which fields can be edited:

  • Sublist line item fields cannot be modified
  • Subrecord fields (e.g., address fields) are also restricted.

Method Return Value

The method returns the internal ID of the parent record after updating the specified fields.

Supported Script Types

This method is applicable in both client and server scripts, making it versatile for various scripting scenarios.

Governance

The governance units consumed by this method are as follows:

  • 10 units for transaction records
  • 2 units for custom records
  • 5 units for all other records

Parameters

The method requires an options parameter, which is a JavaScript object that includes the following fields:

ParameterTypeRequired / OptionalDescription
options.typestringRequiredThe record type being updated. Use record.Type enum for standard records or the custom record type's string ID for custom records.
options.idnumber/stringRequiredThe internal ID of the existing record instance in NetSuite.
options.valuesObjectRequiredID-value pairs for the fields being updated. Values must match field types.
options.optionsObjectOptionalAdditional options for the record update, including:
options.options.enableSourcingbooleanOptionalIndicates if sourcing is enabled during the update (default is true).
options.options.ignoreMandatoryFieldsbooleanOptionalDetermines if required fields are ignored during submission (default is false).

Common Errors

During the execution of this method, one common error may arise:

  • SSS_MISSING_REQD_ARGUMENT: This error is thrown if a required argument is missing or undefined during the method call.

Syntax Example

Here is an example demonstrating how to use the submitFields method:

suitescript
1// Submit a new value for a sales order's memo field.
2var id = record.submitFields({
3 type: record.Type.SALES_ORDER,
4 id: 1,
5 values: {
6 memo: 'ABC'
7 },
8 options: {
9 enableSourcing: false,
10 ignoreMandatoryFields: true
11 }
12});
13
14// Submit a new value for a custom record type.
15var otherId = record.submitFields({
16 type: 'customrecord_book',
17 id: '4',
18 values: {
19 'custrecord_rating': '2'
20 }
21});
22
23// Submit a record with both select and multi-select fields
24var thirdID = record.submitFields({
25 type: record.Type.SALES_ORDER,
26 id: 21882,
27 values: {
28 'custbodycust_txt_fld_custso': 'Hello from custom field',
29 'memo': 'Hello from memo',
30 'leadsource': 254, // select field
31 'custbody_target_market': '1' // custom multi-select field
32 }
33});

Who This Affects:
This update method primarily impacts SuiteScript developers working with record management in applications, enhancing operational efficiency.

Key Takeaways

  • The update method allows inline editing of specified fields without loading the entire parent record.
  • Limited fields can be submitted, including standard and custom inline editable fields.
  • Governance units vary based on the type of record being updated.
  • Common error for this method is related to missing required arguments.

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

Frequently Asked Questions (4)

Does the update method in SuiteScript require loading the entire parent record?
No, the update method allows developers to modify one or more body fields on existing records without loading the entire parent record, enhancing efficiency.
Can we update sublist line item fields or subrecord fields using the update method?
No, sublist line item fields and subrecord fields, such as address fields, cannot be modified using the update method.
What governance units are consumed when using the update method for different record types?
The update method consumes 10 governance units for transaction records, 2 units for custom records, and 5 units for all other records.
What happens if a required argument is missing during the update method call?
If a required argument is missing or undefined, the error 'SSS_MISSING_REQD_ARGUMENT' will be thrown during the execution of the update method.
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 Platform

View all Platform articles →