Has anyone tried using the `N/ui/dialog` module in...
# suitescript
j
Has anyone tried using the
N/ui/dialog
module in a
saveRecord
function from a client script. Would like to use NetSuite's nice looking dialogues instead of the browser's confirm boxes before saving but the dialog methods always generate promises. So I guess the real question is, can you run async code in a
saveRecord
function and have NetSuite wait for it to complete?
b
no, saveRecord is synchronous
take your ugly confirm
😂 1
or add code to do the equivalent of clicking the save button again
j
Shoot, thought that might be the answer. NetSuite should really change that function to be able to return a Promise that resolves to a boolean instead of just a boolean.
j
I wrote my own Notification thingy to run checks on saveRecord and show the nice looking coloured messages at the top if some of the save checks failed
💯 1
Using
N/ui/message
w
I usually go for the same approach as @jen. And if client scripts aren't available, you can do it in aftersubmit. Revert the changes, set a session variable and the redirect to the same page. A beforeload can pick up the session variable and display a message.
j
Revert the changes
do you have a quick/easy way to do this?
w
Nope. Usually just revert those fields that I've setup to validate. So it's not a full revert.
Will probably be very complicated to do if we're talking about many fields and sublists. Then I'd go for the ugly way of throwing an error in beforeSubmit.
z
Do those jquery hacks not work anymore for doing that? Haha