record.submitFields: Update Records Efficiently in NetSuite
The record.submitFields method allows easy updates to body fields on existing NetSuite records without loading the parent record.
The record.submitFields method in NetSuite allows developers to update and submit body fields on existing records efficiently. This method is beneficial as it eliminates the need to load the parent record, streamlining data management processes.
Method Overview
What Does record.submitFields Do?
The method updates specified fields for a record and returns the internal ID of the parent record. The key advantage is that both standard and custom body fields that support inline editing can be modified. However, certain limitations exist regarding the types of fields that can be updated.
Editable and Non-Editable Fields
You can edit:
- Standard body fields that support inline editing.
- Custom body fields that support inline editing.
- Select and multi-select fields.
You cannot edit:
- Sublist line item fields.
- Subrecord fields (like address fields).
Method Return Value
The method returns the internal ID of the parent record being updated, facilitating further operations if needed.
Script Compatibility
This method is compatible with both client and server scripts within the SuiteScript framework.
Governance
Usage of the method is governed based on the type of record being updated:
- Transaction records: 10 units per call
- Custom records: 2 units per call
- All other records: 5 units per call
Parameters
The options parameter is a JavaScript object that includes several properties necessary for executing record.submitFields successfully:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.type | string | Required | Indicates the record type. Use record.Type enum for standard records; string ID for custom records. |
options.id | number | string | Required |
options.values | Object | Required | Key-value pairs for fields to be updated, ensuring values are of the correct type. |
options.options | Object | Optional | Additional options during the record update. Items include enableSourcing and ignoreMandatoryFields. |
Example Usage
Here are some examples demonstrating how to utilize this method:
Update a Sales Order's Memo Field
1var id = record.submitFields({2 type: record.Type.SALES_ORDER,3 id: 1,4 values: {5 memo: 'ABC'6 }7});Update Custom Record Field
1var otherId = record.submitFields({2 type: 'customrecord_book',3 id: '4',4 values: {5 'custrecord_rating': '2'6 }7});Update Fields with Select and Multi-Select Types
1var thirdID = record.submitFields({2 type: record.Type.SALES_ORDER,3 id: 21882,4 values: {5 'custbodycust_txt_fld_custso': 'Hello from custom field',6 'memo': 'Hello from memo',7 'leadsource': 254, // select field8 'custbody_target_market': '1' // custom multi-select field9 }10});Errors
Developers should be aware of error codes that may arise, specifically:
SSS_MISSING_REQD_ARGUMENT: This error is thrown when a required argument is missing or undefined during execution.
This method significantly enhances the efficiency of record management in NetSuite, giving developers more power over how they manipulate data.
Key Takeaways
- The
record.submitFieldsmethod allows efficient updates to NetSuite records. - Developers must specify record types and IDs to utilize this method correctly.
- Different record types have varying governance limits regarding method usage.
- This method does not allow updates to sublist or subrecord fields.
- Developers should handle potential errors related to required arguments carefully.
Frequently Asked Questions (4)
Can the record.submitFields method in NetSuite be used to update sublist line item fields?
What are the governance limits for using record.submitFields on different types of records?
Is the enableSourcing option mandatory when using the record.submitFields method?
What happens if a required argument is missing when executing record.submitFields?
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.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- 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.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category