I would think this wouldn't send an email but it d...
# suitescript
k
I would think this wouldn't send an email but it does
b
you threw a string
k
I need an error on the screen but not an email.
If I send the whole error it comes up as an object but doesn't send the email
but the user doesn't want to see a stringified object on screen
b
you dont really have a choice in this
k
Yeah that's what I was afraid of
b
you can change the email settings in the script
k
this script is used for other things than this error so I'd really rather not turn off all notifications for this script
b
i honestly didnt really expect that to be an option
b
@Kris Wood I ran into this a few times as well, in SuiteScript 1.x, throw nlapiCreateError("XXXX", "Message", true) would show only the "Message" and suppress the emails, in SuiteScript2.x, as @battk has confirmed, you either throw the string (.message) and email goes out, or throw the Object and a JS object is displayed on screen. I've not found a way to change the behaviour. The workaround is a SuiteLet that takes error message and renders a form that shows the error,then you redirect to SuiteLet from the UE = no email & nice error. feels a bit "sledgehammer to crack a nut" however - side note: only tried After Submit .. not sure it would be good to do this in before submit, as record will still be saved...
k
This is beforeLoad because they don't want the edit form to show up at all.
b
redirect to view mode possibly>
k
How is that done from beforeLoad?
and can I pass a parameter to it so it can display a message instead of an error?
b
using the redirect module, redirect.toRecord() - only thing to think about is user journey of clicking edit and it going to view
💯 1
k
yeah, hence using
N/message
to tell them what's going on
b
Problem here is pageInit doesn't run in VIEW mode, so using the N/message module doesn;t work...
k
there's a server side equivalent now
I forget what it's called
but does the same thing
N/ui/message
how do you get URL parameters in a user event script?
b
context.request.parameters?
k
message has been deleted
It's glorious, thank you!!!
👌 1
b
Looking good 🙂