When building custom Suitelets for data entry, approvals, or internal tools, one common challenge is ensuring that users provide complete information for each line in a sublist. Incomplete entries can lead to processing errors, missing data, or additional follow-ups.
A useful technique to address this is making sublist columns mandatory. By enforcing required fields directly in the Suitelet interface, administrators and developers can ensure that users complete critical fields before submitting the form.
Why Make Sublist Columns Mandatory?
Setting mandatory fields on Suitelet sublists helps:
- Prevent incomplete submissions when users add multiple lines.
- Ensure critical data is captured before processing transactions.
- Reduce validation errors during backend processing.
- Improve data accuracy in custom workflows and approval processes.
This is especially useful in Suitelets designed for expense entries, approvals, bulk updates, or custom data intake forms.
Using the isMandatory Property
In SuiteScript, the isMandatory property can be used to enforce required input on fields created with the N/ui/serverWidget module.
When applied to a sublist field, it requires users to enter a value in that column for each line before submitting the form.
Important:
This property only applies to fields created dynamically in Suitelets or custom UI generated with serverWidget.
Example: Suitelet with a Mandatory Sublist Column
The following example demonstrates how to:
- Create a Suitelet form
- Add an editable sublist
- Set a column as mandatory
- Log the mandatory status for debugging
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
*/
define(['N/ui/serverWidget', 'N/log'], function(serverWidget, log) {
function onRequest(context) {
// Create the Suitelet form
var form = serverWidget.createForm({ title: 'Mandatory Column Example' });
// Add a sublist to the form
var sublist = form.addSublist({
id: 'custpage_list', // Sublist internal ID
label: 'Sample Sublist', // Sublist label as shown to the user
type: serverWidget.SublistType.INLINEEDITOR // Allows inline editing
});
// Add a column (field) to the sublist
var col = sublist.addField({
id: 'custpage_col', // Column internal ID
label: 'Required Column', // Column label as shown to the user
type: serverWidget.FieldType.TEXT // Column type is text
});
// Make the column mandatory in the UI
col.isMandatory = true;
// Log the isMandatory property for this column
log.debug({
title: 'Is Column Mandatory?',
details: col.isMandatory // Will log 'true'
});
// Add a submit button to the form
form.addSubmitButton({ label: 'Submit' });
// Display the form to the user
context.response.writePage(form);
}
return { onRequest: onRequest };
});
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!