Hi All, I am trying to create custom error with er...
# suitescript
s
Hi All, I am trying to create custom error with error.create api. I can see the error in log but email didn't send. Please help. I have set the notifyOff false. Script type is user event. Thanks throw error.create({ name: type, message: message, notifyOff: false });
b
Error messages have more to do with the Unhandled Errors from the script record
If you are working in a sandbox, then Preferences for Sandbox Email may be the issue
If you think you did everything correctly, then follow the Troubleshooting Undelivered Email topic
s
Thank you @battk. Actually i want to send email with error message, if the response code is 400. Can we do it using error.create api or I need to use email.send?
b
thats what the unhandled errors are for
s
But it is not working. Script executes further if code is 200 or 201 only
b
are you eventually catching the error
s
I am trying to throw the error using error.create api if cpde is not 200/201
b
are you eventually catching the error
s
No
b
that means that the thrown error is handled by the unhandled errors of the script
who is setup to receive emails on the script record
s
I have set my email in notify emails field
b
are you on a sandbox?
s
yes. In email preferences, i used both option SEND EMAIL TO LOGGED IN USER, SEND EMAIL TO (SEPARATE ADDRESSES WITH COMMAS) one by one
But it didn't work
b
what was it before
s
SEND EMAIL TO LOGGED IN USER
b
as in when the sandbox was refreshed
this setting comes from production
whatever it was originally is what is in the sandbox now
s
Not sure but i think 4 or 5 month ago
b
what is it now?
in the sandbox?
s
Sorry didn't get your point
b
if it started out as
SEND EMAIL TO LOGGED IN USER
then you should be able to find the emails in the inbox of your netsuite login email
if its not there, you need to follow the troubleshooting directions to see if netsuite sent the email and if it bounced
s
I have checked it. These are not the cause of the issue. Not sure but i think i am doing somethin wrong in error.create api
b
if you dont see the email in the sent email list, then netsuite didnt even try to send the email
you can try directly using email.send, but the normal error handling process is determined by the unhandled errors on the script record and the sandbox email preferences
s
yes but i am setting the notifyOff: false. The script type is user event. Do you think this is not possible in user event script?
b
its possible for user event scripts to send errors in sandbox accounts
the code you shared is enough to throw an error
assuming you dont catch it in other parts of your code
s
Thank you so much. Appreciate your help