What do you mean by submit without touching the dom? You can submit the record with record.save()?
m
mayerlench
05/21/2020, 9:42 PM
save() isnt a function on currentRecord.
I want to prompt the user a notification onSave and allow them to click yes or no to save, therefore i need be able to hit submit for them.
a
amy
05/21/2020, 9:59 PM
i think if you return true in onSave it saves the record, and returning false just returns them to the record page. does that not work for your scenario?
m
michoel
05/21/2020, 11:02 PM
You could use window.confirm which is synchronous but I'm guessing you want something prettier? Until NetSuite either allows returning a promise to onSave or an API to submit you have to use JS to click the button yourself.
m
mayerlench
05/22/2020, 12:56 AM
Thanks michoel. I never had to do something like this. Figured maybe there was some undocumented way of saving using the currentRecord api but will just use the window to submit the form
mayerlench
05/22/2020, 12:59 AM
@amy I want to prompt the user if they want to save with a yes or no button. The prompt returns a promise and as michoel pointed out, you must return true or false from the onSave function
s
Stephen Boot
05/22/2020, 10:51 PM
The safest way is to use window.confirm, but if you really want to use N/ui/dialog promise, then you need to return false in your onSave function and submit the form when your promise resolves using JavaScript. I have used document.getElementsByName('main_form')[0].submit() but DOM manipulation is risky and you should be prepared to update your code if NetSuite changes their DOM structure in any future release.