6 Inline Editing in SuiteScript 2.0
June 5, 2017 12:00 am
Prefer a video? Watch here (9 minutes)
NetSuite’s inline editing feature allows users to very quickly modify and update the data for a particular record without having to load the entire record on a page, edit the form, then save the record.
NetSuite developers can also leverage inline editing via SuiteScript’s
submitFields functionality. This feature is provided by the
nlapiSubmitField function in SuiteScript 1.0 and the
N/record#submitFields method in SuiteScript 2.0.
As with most of the record functionality we’ve seen so far, there is a 1:1 relationship between the SuiteScript 1.0 and 2.0 inline editing functionality. The 2.0
submitFields function has the same options provided by the 1.0
nlapiSubmitField function. We can set a single field or multiple fields, and when we do so, we can determine whether sourcing should occur and whether to ignore mandatory fields.
The best way to illustrate the actual usage will be through an example.
Example: Editing a Single Field
Let’s start with a simple example in the
afterSubmit of a User Event deployed to the Sales Order record. We’ll use inline editing to set the default shipping item for the associated Customer.
Example: Editing Multiple Fields
We can also inline-edit multiple fields with a single call; let’s update our example to also set a comment on the Customer when we update the shipping item. We’ll also look at how to specify the sourcing and mandatory fields options.
Notice in 2.0, we just need to add more key-value pairs to the
values Object to update more fields, and we specify the sourcing and mandatory fields settings using the
As handy and effective as inline editing can be, it also has its drawbacks and limitations. Let’s take a look at some of the pros and cons of inline editing.
Advantages and Limitations of Inline Editing
The largest advantage of inline editing is that it executes faster and uses less governance than loading the record, modifying the fields, and saving the record. This works on both standard and custom records. It also involves significantly less code, which is always nice.
Unfortunately, not all fields are inline-editable.
Sublists are not inline-editable; if you need to work with sublist fields, you will need to load the record.
Further, select fields (dropdowns) and subrecord fields (like addresses) are not inline-editable either. To work with these fields, you’ll need to load the record.
Finally, only very specific fields on each record type are inline-editable; to determine which ones are inline-editable, you need to check the “nlapiSubmitField” column in the Records Browser.