ANS-1140 · SUITESCRIPT DEVELOPMENT
How to Handle Record Updates with xedit, DLE, and nlapiSubmitField in NetSuite
Understand the specific behaviors of NetSuite's xedit event type, including direct list editing and mass updates, when scripting record interactions.
Short answer
NetSuite's `xedit` event type is triggered by direct list editing, mass updates, or `nlapiSubmitField`. During `xedit`, `nlapiGetFieldValue()` and `nlapiGetNewRecord().getFieldValue()` return null for unchanged fields. Use `nlapiLoadRecord()` to retrieve all current field values, including those not modified by the `xedit` action.
Scenario
Developers often encounter situations where scripts need to interact with records updated through NetSuite's direct list editing (DLE), mass update features, or the `nlapiSubmitField` API. Understanding the specific behaviors of field retrieval functions during these `xedit` events is crucial for accurate data processing and script logic.
Solution
The xedit event type is triggered when a record is updated through direct list editing (DLE), a Mass Update, or the nlapiSubmitField(...) API. These actions are all categorized as "xedit" type actions for scripting purposes.
When an xedit event occurs, nlapiGetFieldValue() and nlapiGetNewRecord().getFieldValue() will return null when attempting to read a field that was not explicitly changed by the xedit operation. To retrieve the value of such fields, it is necessary to perform a full record load using nlapiLoadRecord().
It is important to note that a field that was submitted by an xedit action will return its CURRENT, updated value when read by nlapiLoadRecord(). For advanced handling of these scenarios, refer to IT_Standard_Library.js.
Please be aware that the functions discussed (nlapiGetFieldValue, nlapiGetNewRecord, nlapiLoadRecord, nlapiSubmitField) are part of SuiteScript 1.0. For new development, SuiteScript 2.x is the recommended API version.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
