Submit Fields Programmatically with SuiteScript in NetSuite
Submit fields programmatically using SuiteScript in NetSuite, enabling efficient updates without loading parent records.
Starting in NetSuite, the record.submitFields method provides a streamlined approach to update and submit body fields on existing records. This method allows developers to make adjustments without needing to load or submit the parent record directly. It is particularly useful for making quick changes to standard or custom fields that support inline editing.
What Can You Update?
This method can be utilized to edit and submit the following:
- Standard body fields that support inline editing.
- Custom body fields that allow inline editing.
- Select and multi-select fields.
Limitations
However, the record.submitFields method cannot be used to modify:
- Sublist line item fields.
- Subrecord fields (like address fields).
Return Value
Upon successful submission, this method returns the internal ID of the parent record that has been updated.
Supported Script Types
The record.submitFields method works with both client scripts and server scripts. This makes it versatile for a variety of use cases in NetSuite.
Governance
The governance units consumed by this method vary based on the type of record being updated:
- Transaction records: 10 units
- Custom records: 2 units
- All other records: 5 units
Parameters
The options parameter is a JavaScript object that contains the following fields:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.type | String | Required | Specifies the record type. Use record.Type enum for standard records; use the custom record type's string ID for custom records. |
options.id | Number | String | Required |
options.values | Object | Required | An object of ID-value pairs for fields you want to edit. The value type must match the field type (e.g., strings for text, booleans for checkboxes, etc.). |
options.options | Object | Optional | Additional options for the record, such as enabling sourcing or ignoring mandatory fields during submission. |
Example Usage
Here are some sample usages of the record.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 field on 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, //leadsource is a select field31 'custbody_target_market': '1' // multi-select field32 }33});Errors
If a required argument is missing, the following error code will be thrown:
SSS_MISSING_REQD_ARGUMENT: Indicates that a required argument is missing or undefined.
Conclusion
The record.submitFields method simplifies the updating process in NetSuite, allowing quick edits while observing governance limitations. It plays a key role in enhancing the user experience by improving the efficiency of record management.
Key Takeaways
- Use
record.submitFieldsto update records without loading parent records. - Supports inline editing for standard and custom body fields.
- Cannot be used to alter sublist or subrecord fields.
- Consumes different governance units based on record type.
- Provides flexibility for client and server-side script implementations.
Frequently Asked Questions (4)
Can the record.submitFields method be used to update sublist line item fields?
What script types are compatible with the record.submitFields method in NetSuite?
How do governance units vary when using the record.submitFields method?
What happens if a required argument is missing when using the record.submitFields method?
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