Adam Weaver
04/09/2025, 10:21 AMCeligo AI
04/09/2025, 10:22 AMAI generated answer (using internal Slack threads):Yes, you can make a field mandatory on a scripted record in NetSuite. This can be done using SuiteScript, specifically within a User Event (UE) script or a Client script. In a User Event script, you can use the
isMandatory
property to make a field mandatory. Here is an example:
code
function beforeLoad(scriptContext) {
if (scriptContext.type !== scriptContext.UserEventType.CREATE)
return;
var form = scriptContext.form;
var field = form.getField('custbody_some_custom_field');
field.isMandatory = true;
}
In a Client script, you can also use the isMandatory
property, but it should be noted that this will only add a visual indicator (a red asterisk) next to the field. It does not actually enforce the field to be mandatory. Here is an example:
code
function pageInit(scriptContext) {
var currentRecord = scriptContext.currentRecord;
var field = currentRecord.getField('custbody_some_custom_field');
field.isMandatory = true;
}
To enforce the field to be mandatory in a Client script, you would need to add a validation in the saveRecord
entry point to check if the field is empty or not. If it's empty, return false to prevent the record from being saved and provide an alert to the user. Here is an example:
code
function saveRecord(scriptContext) {
var currentRecord = scriptContext.currentRecord;
var fieldValue = currentRecord.getValue('custbody_some_custom_field');
if (!fieldValue) {
alert('Please fill in the mandatory field.');
return false;
}
return true;
}
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/09/2025, 10:22 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854351461
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846110225
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845525503
Celigo AI
04/09/2025, 10:22 AM