Trying to find a better way to throw/display an er...
# suitescript
j
Trying to find a better way to throw/display an error on a User Event / BeforeSubmit function callback. I keep seeing in the documentation that the
N/error
module isn't supported in UE script types. I've tried playing around with
N/ui/message
and
N/ui/dialog
but also having a hard time getting anything to fire beforeSubmit. Scenario: Check for duplicate records on a custom record type; if a duplicate record is found; throw error.
Copy code
function showError() {
                        let myCustomError = error.create({
                            name: 'DUPLICATE_ERROR',
                            message: "A vaccination report record already exists for this employee.",
                            notifyOff: false
                        });

                       
                        log.error('Error: ' + myCustomError.name, myCustomError.message);
                        throw myCustomError;
                    }
The problem is that this error message is hard to follow for some of my end users. I'm hoping to either clean up the body of the error message. Or really simplify it down to a one line error message.
b
be a menace and throw a string
🙏 1
you can be more normal and throw an Error too
j
wow. Thank you.. I'm embarrassed to admit how much time I just wasted.. Throwing a string is exactly what I needed.
b
throwing an Error is far more normal, though less fun
338 Views