Error Handling and Update Method in SuiteScript
Learn error handling and methods for updating records in SuiteScript, optimally managing field submissions.
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:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.type | string | Required | The record type being updated. Use record.Type enum for standard records or the custom record type's string ID for custom records. |
options.id | number/string | Required | The internal ID of the existing record instance in NetSuite. |
options.values | Object | Required | ID-value pairs for the fields being updated. Values must match field types. |
options.options | Object | Optional | Additional options for the record update, including: |
options.options.enableSourcing | boolean | Optional | Indicates if sourcing is enabled during the update (default is true). |
options.options.ignoreMandatoryFields | boolean | Optional | Determines 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:
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: true11 }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 fields24var 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 field31 'custbody_target_market': '1' // custom multi-select field32 }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.
Frequently Asked Questions (4)
Does the update method in SuiteScript require loading the entire parent record?
Can we update sublist line item fields or subrecord fields using the update method?
What governance units are consumed when using the update method for different record types?
What happens if a required argument is missing during the update method call?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
