James Morris
03/05/2025, 6:45 PMCeligo AI
03/05/2025, 6:45 PMAI generated answer (using internal Slack threads):Yes, it is possible to use
setMandatory
in a client-side script in NetSuite, but it does not enforce the field to be mandatory on the server-side. This means that even if you set a field to be mandatory on the client-side, the record can still be saved without providing a value for that field.
The setMandatory
function in a client-side script only visually indicates to the user that the field is mandatory by adding an asterisk next to the field. However, it does not prevent the user from saving the record if the field is left empty.
To enforce the mandatory requirement, you need to manually validate whether the field is empty or not in the saveRecord
event. If the field is empty, return false
which will not let the user save the record. You can also provide an alert to inform the user why the record is not saved.
Here is an example of how you can do this:
javascript
function saveRecord(context) {
var currentRecord = context.currentRecord;
var myField = currentRecord.getField({fieldId: 'myField'});
if (!myField.value) {
alert('Please fill out the mandatory field.');
return false;
}
return true;
}
Please note that this method works as long as the field can be edited. If the field is read-only, you cannot set it to be mandatory.
******
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
03/05/2025, 6:46 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862302423
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.856736839
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852647126
Celigo AI
03/05/2025, 6:46 PM