Is there anyway with a beforeLoad user event scrip...
# suitescript
m
Is there anyway with a beforeLoad user event script to prevent the record from being saved and redirect the UI to a different page?
I figured out one way which is technically an XSS attack `throw 'You cant save this record. You will be redirected soon. <img src="#" onerror="window.location=`https://google.com`;" />'`
Hoping there is something more supported
e
Wouldn't you catch this in a beforeSubmit and redirect using the redirect module? Or if you catch the scenario in beforeLoad you can do the same.
m
The script I'm working on is 1.0. I tested nlapiRedirectUrl but it didn't do anything in a beforeSubmit
Another option I came up with is move the logic to afterSubmit and if the record shouldn't have been allowed to be created, delete it and then redirect
e
Can't you prevent a save in beforeSubmit? You still may be able to redirect in the afterSubmit...
m
I'm preventing the save in beforeSubmit by throwing an error. Just tested this to be sure, but if I throw an error in beforeSubmit, then the afterSubmit doesn't run