Maintaining clean and accurate data is critical for reporting, compliance, and operational efficiency. One simple but powerful way to protect your data is by disabling fields—making them read-only so users can view values but cannot modify them.
This Admin Tip walks you through the different ways to disable fields, whether through form customization or scripting.
Method 1: Disable a Field Using Custom Forms (No Coding Required)
This is the simplest and most secure approach for most use cases.
Steps:
1.Navigate to Customization > Forms > Entry Forms
2. Edit the desired custom form.
3. Go to the Fields or Sublists tab.
4. Locate the field you want to restrict.
5. Change the Display Type to:
- Disabled – Field remains visible but read-only.
- Inline Text – Field appears as plain text (not editable and does not look like an input field).
6. Save the form.
Use Disabled if you still want the field to look like a form field but prevent edits.
Use Inline Text if you want it to appear as static information.
This method is ideal when the rule applies to all users of that form.
Method 2: Disable a Field Using SuiteScript (Server-Side)
If you need conditional logic (for example, disable a field based on status, role, or record type), use server-side scripting.
Example (SuiteScript 2.x – Suitelet)
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
*/
define(['N/ui/serverWidget'], function(serverWidget) {
// Suitelet entry point
function onRequest(context) {
// Only generate the form on GET requests
if (context.request.method === 'GET') {
// Create a new form
var form = serverWidget.createForm({
title: 'Sample Form'
});
// Add a text field to the form
var field = form.addField({
id: 'custpage_myfield', // Field ID (unique within the form)
type: serverWidget.FieldType.TEXT, // Field type
label: 'My Field' // Field label
});
// Set the field to be disabled (read-only)
field.updateDisplayType({
displayType: serverWidget.FieldDisplayType.DISABLED
});
// Display the form to the user
context.response.writePage(form);
}
}
return {
onRequest: onRequest
};
});
Use server-side disabling when:
- The field should only be disabled under certain conditions.
- You want stronger enforcement (cannot be bypassed via browser tools).
- The logic depends on record status, user role, or business rules.
Method 3: Disable a Field Using Client Scripts (Client-Side)
Client scripts allow dynamic behavior based on user interaction, such as disabling a field after a value changes.
Example (SuiteScript 2.x – Client Script)
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define([], function() {
// Runs after the form is initialized in the browser
function pageInit(context) {
// Get the current record object in the UI
var currentRecord = context.currentRecord;
// Access the specific field by its ID ('custbody_customfield')
// and set its isDisabled property to true (make read-only)
currentRecord.getField({
fieldId: 'custbody_customfield'
}).isDisabled = true;
}
return {
pageInit: pageInit
};
});
The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
To know more about deploying SuiteScript, check these New to NetSuite Articles.
Do you have another way on how to automate your transactions using SuiteScript? Feel free to share them here!