hello team, question related to a User Event scrip...
# suitescript
a
hello team, question related to a User Event script. When you create a Workflow, one of the Actions you can create is to Return User Error. What is the equivalent of this Action in SuiteScript? In my User Event script, I am using throw error, but this also sending an email, etc. Is there a less intrusive way to set an error similar to the workflow action?
s
from the documentation you can try
Copy code
var custom_error = error.create({
    name: 'MY_ERROR_CODE',
    message: 'my custom error details',
    notifyOff: true
});
a
I am doing that, but then I throw that error
do I need to throw it?
s
yes, when you throw it you get an email?
a
don’t know… I thought it was necessary to throw it
s
Actually I could be wrong, looking at documentation again the error module isn't supported in UE 😆
maybe throw the error, but on the script record modify the notify owners?
also is your throw in a catch?
a
no, no catch
s
maybe it catch it
since, the notify section of the script record says "Unhandled Errors"
s
You can definitely create errors and throw them in UE
a
all right guys, so, I think I figured it out
if you throw an error, like this:
var myError = error.create({ name: ‘ACTION_NOT_ALLOWED_FOR_ROLE’, message: errorMessageText, notifyOff: false }); throw myError.message;
it will also send an email saying there was an exception in your script, blah blah blah
but, if you instead just throw a text string, like this:
throw errorMessageText;
it does not send the exception email
good to know I guess 🙂
thanks all for your help
b
please dont throw strings, that will only confuse the next developer
or any other code that has to work with your script
a
thanks for the feedback, I agree that having the exception and all the info is the best way to go
in this case though, I don’t want thatt
m
If you don't want an email notification then disable that on the script deployment
a
where do I disable that? I am looking at the deployment of the User Event script. I don’t see that option
m
Sorry it's on the script record, not deployment
message has been deleted
a
great, thanks