In SuiteScript, the submitFields() function is a powerful method provided by the N/record module that allows developers to update fields on a record without loading the entire record into memory. This makes it an efficient choice for updating one or more fields on a record, especially when dealing with large datasets or needing to perform quick updates.
The submitFields() function updates specified fields on a record and saves the changes immediately. This function is particularly useful when you need to update a record quickly without the overhead of loading and saving the entire record.
Syntax:
record.submitFields(
{
type: record.Type.RECORD_TYPE,
id: recordId,
values:
{
fieldId1: value1,
fieldId2: value2, // additional field-value pairs
},
options:
{
enableSourcing: false,
ignoreMandatoryFields: true
}
});
- type: The type of the record to update (e.g., record.Type.CUSTOMER).
- id: The internal ID of the record to update.
- values: An object containing field IDs and their new values.
- options (optional): An object to specify additional options:
- enableSourcing: If true, sourcing is enabled during the record update.
- ignoreMandatoryFields: If true, mandatory fields can be ignored.
The submitFields() function in SuiteScript is a valuable tool for efficiently updating record fields without the overhead of loading the entire record. By understanding its syntax and practical applications, you can leverage submitFields() to streamline your NetSuite customizations and automate business processes effectively. Whether updating a single field or multiple fields, submitFields() provides a straightforward and powerful way to modify records quickly.