Hi All, how can we prevent record from being saved...
# suitescript
s
Hi All, how can we prevent record from being saved on before submit event?
w
throw an error
s
Ok, thanks why return false is not work?
w
It's not how Netsuite built it.
s
ok
Thanks for the response.
it will throw the error but it does not prevent the record from being saved. if it throws an error, we don't save the record
w
it will throw the error but it does not prevent the record from being saved.
sounds like the opposite of
if it throws an error, we don't save the record
What does your code look like?
s
function beforeSubmit(context) { try { var checkValue = true if (checkValue) { // recordObj.clientScriptModulePath = './Alert for User.js'; // showAlert(); throw error.create({ name: 'Customer Restrictions', message: 'Cannot save the record due selected Customer.' }); } } catch (e) { log.debug('e', e); } } I deployed this acript on SO and I'm trying to edit and save.
w
you are catching the error and then you are not doing anything to prevent the save. you need to re-throw the error after log.debug() (which should probably be changed to log.error()
s
Ok
w