ANS-0415 · SUITESCRIPT DEVELOPMENT
How to Hide NetSuite Fields While Maintaining Script Access
NetSuite offers multiple methods to hide fields on records, including UI configuration and scripting, each with specific implications for different field types and script contexts.
Short answer
NetSuite fields can be hidden via form customization or SuiteScript. When a field is script-dependent but should be invisible, the method depends on field type (body vs. column) and script context (server-side vs. client-side). Server-side scripts can hide fields programmatically, while client-side interactions with hidden fields require careful consideration.
Scenario
NetSuite users often encounter situations where a field on a record is essential for script functionality but should not be visible to end-users. Determining the optimal method to hide such fields while ensuring scripts can still interact with them effectively can be challenging, as different field types and script contexts have varying behaviors.
Solution
NetSuite provides two primary methods for hiding fields on a record:n
Hide the field directly on the form using UI customization.n
Hide the field programmatically using SuiteScript.
When a script interacts with a field that needs to be hidden from the user interface, the appropriate method depends on the field type and the script's execution context (server-side or client-side).
SuiteScript 2.x Examples for Hiding Fields:
For Body Fields (Server-Side - User Event/Suitelet):n
javascriptn// Assuming 'scriptContext.form' is available in a User Event or Suitelet scriptnscriptContext.form.getField({ id: 'FIELDID' }).updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });nFor Body Fields (Client-Side - N/currentRecord):n
javascriptn// Assuming 'currentRecord' is an instance of N/currentRecord in a Client ScriptncurrentRecord.getField({ fieldId: 'FIELDID' }).isDisplay = false;nFor Sublist Column Fields (Server-Side - User Event/Suitelet):n
javascriptn// Assuming 'scriptContext.form' is available in a User Event or Suitelet scriptn// Example for 'item' sublist and 'custcol_mycolumnid' columnnvar sublist = scriptContext.form.getSublist({ id: 'item' });nif (sublist) {n var columnField = sublist.getColumn({ id: 'custcol_mycolumnid' });n if (columnField) {n columnField.updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });n }n}nRecommendations for Fields Used by Scripts:
For Body Fields:
Both form customization and scripting can be used to hide body fields. Scripts will retain the ability to set and read values for these fields regardless of the hiding method.
For Sublist Column Fields:
For Server-Side Scripts (User Event, Suitelet, RESTlet, Mass Update):
Sublist column fields can be hidden using scripting. Server-side scripts will still be able to set and read the field's value.
For Client-Side Scripts:
For client-side scripts, directly hiding sublist column fields using client-side APIs is more complex and limited. The isDisplay property for sublist fields is not available in dynamic mode and is read-only in the N/currentRecord module. Therefore, if a sublist column field needs to be hidden but still interacted with by a client-side script, it is generally recommended to hide the field via form customization or a server-side script (e.g., a User Event script).
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
