NetSuite’s record.submitFields method efficiently updates specific fields on a record without loading it. To update the custom field custbody_jj_custfield on a sales order:
const BODY_CUSTFIELD = 'custbody_jj_custfield';
record.submitFields({
type: record.Type.SALES_ORDER,
id: soId,
values: {
[BODY_CUST_FIELD]: true
},
options: {
enableSourcing: false,
ignoreMandatoryFields: true
}
});
Why []?
Use square brackets [BODY_CUST_FIELD] to dynamically reference the field ID (custbody_jj_custfield). Without them, NetSuite looks for a field named BODY_FIELD_ALREADY_PRINTED, causing failure.
Advantage
If the field ID changes, update only the BODY_CUST_FIELD constant. This simplifies maintenance when the field is used across multiple scripts.