hello, i have put a logic in a beforeSubmit UE tha...
# suitescript
s
hello, i have put a logic in a beforeSubmit UE that throws a new error, in hopes of stopping the order from saving, it works based on the log but not sure why the transaction is still saving
this is the code block
am i missing something? i have used the code above on other instance and it works and throws an error thus preventing the transaction save
r
is there any try catch in this script?
s
i removed the try catch….
it’s only an if and then throw error, not really sure why it’s allowing it to save
b
remove all the code and make a beforeSubmit that only logs that it runs and then throws your error
s
i did try that, and the error is coming up on the logs. but the transaction is still saving..
b
what does the log look like
s
like this, it seems working as expected
b
thats not what you want
that from log.error
thrown errors are system level
what does your script look like
s
if (!areAllItemAvailable) {
throw new Error("Some item(s) are unavailable or have insufficient quantity. " +
"<p>Item(s) " + unavailableItemErrText + "</p>");
}
b
thats a fragment of the scripts
you need to share the entire thing
importantly, what you shared is not what i told you to do, make a script that only logs and throws you error
none of that other logic
s
oh, the functions just calls a search that iterates if the available inventory is 0 or not, then the result is transferred to areAllItemAvailable and the value of that before the error is [], trying the log,error now