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.
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?
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 Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category