The quick answer
In a User Event beforeLoad entry point, get the sublist field through context.form, then call updateDisplayType on that serverWidget.Field. For the Invoice Item column, use the item sublist and item field. A record.Record returned by setSublistValue does not have updateDisplayType. An EDIT guard lets you hide the column while editing and keep it visible in View.
The company and person names are fictional example data. The walkthrough uses a local code editor and API exercise to show the object difference. Saving or running that local file does not upload or deploy a script in a NetSuite account.
Before you start
For account use, Server SuiteScript must be enabled and the testing role must be able to open the invoice. Maintaining source files, script records, and deployments requires the relevant account permissions; the exact permission set depends on the role and setup. Visible columns and access to item.item can vary with the invoice form, features, role, mode, and other customizations. Verify the IDs and form structure for the context being tested.
The code must be in the File Cabinet file associated with a User Event script record. Confirm the deployment applies to Invoice and is deployed. Testing generally limits execution to the script owner; check ownership, status, audience, and execution role separately for the intended account context. Then open a fresh invoice form. The recording inspects prepared script settings; it does not perform that production setup.
01. Inspect the invoice
INV-6832 for Spruce Harbor Equipment has one Relay Sensor line. Quantity 3 × rate 48.00 gives an amount of 144.00. The displayed invoice total is also 144.00.
The Item column is visible in View. Keep this invoice and its line as the comparison point.
02. Read the object error
The incorrect assignment calls context.newRecord.setSublistValue(...) and stores its return value in recordField. That value is a record object. The next line calls a UI-field method on it:
recordField.updateDisplayType({
displayType:
serverWidget.FieldDisplayType.HIDDEN
});
The local API harness raises TypeError: recordField.updateDisplayType is not a function. The harness uses stand-in record and form objects. This is an illustrative local execution, not an account Execution Log entry. The attempted data-setting call is unnecessary when the goal is to hide a column.
03. Use the form field
Replace the assignment with the form, sublist, and field chain. Keep the EDIT guard and export beforeLoad:
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/ui/serverWidget'],
(serverWidget) => {
function beforeLoad(context) {
if (context.type !==
context.UserEventType.EDIT) return;
const recordField = context.form
.getSublist({id: 'item'})
.getField({id: 'item'});
recordField.updateDisplayType({
displayType:
serverWidget.FieldDisplayType.HIDDEN
});
}
return {beforeLoad};
});
The example assumes the sublist and field exist. Verify the IDs and form structure before using the chain. Missing objects can produce API errors; handle the actual behavior of the forms and contexts your script supports.
In the recording, the corrected source is typed, saved as a local file, and used by Run local exercise. The local output reads item.item: hidden. This applies the saved bytes to the local example. For a real account, the corrected bytes must reach the associated File Cabinet file before the form is reloaded.
04. Check the prepared script
The following script, file association, and deployment already exist as prepared example configuration. This walkthrough inspects them; it does not create, upload, save, deploy, or execute account changes.
Open Customization > Scripting > Scripts, then Invoice Column Display. The prepared script is a User Event script using API Version 2.1. Its Scripts subtab names invoice_column_display.js and has Before Load Function checked.
On Deployments, the prepared row applies to Invoice, has Deployed Yes, and Status Testing. The script owner in this example is Alex Morgan. Testing generally limits execution to that owner. Check ownership, status, audience, and execution role separately in the account.
05. Compare Edit mode
Reopen INV-6832 and click Edit. This result is entirely local: the saved source controls the example form. The Item header is absent; the line still shows quantity 3, rate 48.00, and amount 144.00. Description and the other columns shown in this example remain. This comparison does not test adding new lines or every edit capability.
06. Cancel and check View
Click the invoice's Cancel button without saving and return to its View page. In this example, Cancel returns there directly. Item and Relay Sensor are visible again in View. The line still has quantity 3, rate 48.00, and amount 144.00. The EDIT guard changes the displayed form; it does not erase the saved item.
Common questions
Why does updateDisplayType fail on a record object?
The record object provides data methods. updateDisplayType belongs to a serverWidget.Field. Get that field from context.form, then its sublist, then getField. setSublistValue returns the record object and does not obtain the UI field.
Does HIDDEN delete the Item value?
No. It changes the field's presentation on the form being loaded. It does not remove the field or its saved line value. The walkthrough cancels the edit and confirms the original item and amount remain visible in View.
Why is the column still visible in View?
The example returns immediately unless the event type is EDIT. View, Create, Copy, and other event types therefore receive no display change from this code.
Is hiding a column a security control?
No. Users and integrations may still access data through other permitted paths. Use appropriate permissions and server-side enforcement for access and validation requirements.
Does saving the local file update a NetSuite deployment?
No. For account use, put the corrected source in the File Cabinet file referenced by the User Event script record, confirm the applicable deployment, and open a fresh form. The local exercise does not perform those account changes.
Why might the field not be found on another form?
Sublist and field availability depends on the form, mode, role, features, and other customizations. Check the deployment context as well as the IDs. Handle the API errors and form variants your script supports; a null check alone does not establish the right field.