To prevent saving a record and display a specific error message in NetSuite, use the following approach in your SuiteScript:
let errorView = error.create({
name: ‘TITLE’,
message: ‘Error: write the error message.’,
notifyOff: true
});
throw errorView.message;