is there any way to display errors nicely when the...
# suitescript
e
is there any way to display errors nicely when they occur on a record/transaction? Say you are validating in beforeSubmit and need to prevent the save operation, you throw an error and the NS output is the stringified error object… not exactly user friendly.
r
You can print error.code and error.message. Instead of printing the error ?
e
i need to “throw” the error in order to keep the system from saving the record. then, I am stuck and at Netsuite’s mercy to display correctly; which they don’t - they simply print the error object. In a perfect world, I would let NS know not to save, then redirect to the record passing a parameter that I can then display how i would like in a N/ui/message WARNING or ERROR
my issue is, how else can i stop execution of the save
n
You could use a client scripts saveRecord function paird with the N/ui/dialog module to throw a popup on the screen with your message. Then return false out of the saveRecord function to prevent the save from occurring
💯 1
message has been deleted
e
100%. But, that’s client side. Imagine I’m on an Item Fulfillment (this is the scenario, actually) and the user is clicking the Marked as Shipped button…
I need to be able to catch and interrupt the save operation somehow on the server
n
hmmm interesting problem. Maybe a beforeSubmit that validates and redirects the page back to the IF screen if the criteria isnt met
e
that’s the “throw” in the beforeSubmit function
I tried redirect, but the Shipped goes through. the save happens. (it’s an XEDIT in the end in that use case)
I can remove the button, but wish I could handle still. wondering if there’s any other way to STOP execution and display a pretty message, or redirect, etc
n
Ah yeah the native buttons are always difficult to deal with. Maybe you could hide the button like you said with a beforeLoad and use the message module to put a banner at the top of the screen alerting the user why its hidden
n
Throw and don't catch your chosen text. It won't be "pretty" but it will be plain text and not have some user unfriendly stringified object displayed.