Does anyone know how to handle the UI errors in Netsuite Suitescript? I have a script that runs perfectly under normal circumstances. The script loads a sales order and checks a check box then submits the order. The error I receive is if the customer is on a hold(like a credit hold or slow payment hold) it stops execution of the script, which is bad. Is there a way to handle this either by skipping this particular order(which would be fine) or by submitting the order regardless of that message? I looked in their API but did not see anything that I thought would be useful. I am new to Netsuite and JS so maybe I am not looking for the correct solution. Any help is appreciated.
-
1Your question is too generic I think. Provide some code for a topical answer. Generally speaking, you can use the `try{}catch(e){}` paradigm to handle a lot of error situations. It's likely there's a more elegant solution for your use case however. – Shea Brennan Mar 18 '16 at 21:49
-
It will mostly depend on *when* this error is thrown. If you are working in say a client or user event script, and the error is thrown by one of your NetSuite API calls, then you should be able to wrap that call in a try-catch and handle/suppress the error accordingly. However, if the error is thrown between two script events, i.e. between *SaveRecord* on the client and *BeforeSubmit* on the user event, or between *BeforeSubmit* and *AfterSubmit* on the user event, then there won't really be any way for you to handle it. – erictgrubaugh Mar 19 '16 at 03:53
2 Answers
Actually it sounds like the error is trying to stop submission of the order when there is a credit hold - this is likely as the result of another user event script.
If you are really sure you want to submit the order regardless of other business scripts you can do nlapiSubmitRecord(soRec, {disabletriggers:true, enablesourcing:false, ignoremandatoryfields:true});
.
Of course what you have now done is bypassed most scripted checks on the SO. I generally only do this when I am either running some sort of fix/irregular update to backfill fields or when I am updating a flag that is managed only by my custom functionality. (e.g. on success after queuing a record for transmission to an external system -- this is not a great assumption and I don't generally do this)

- 14,408
- 2
- 18
- 31
Try using a block like:
try { trysomething (); }
catch (e) { handle_error(); }
finally { some_default_thing(); }
Can handle most unforeseen circumstances. Put your main code under try
. Then your default, fallback action in the finally
block, while handling the error conditions in the catch
block.
Do you have any more details to share?

- 1,117
- 8
- 18
-
Well the error is generated in Netsuite not JS. It is an error stating something about the customer. I will try the above code when I get back home and see if that helps at all. – Mike A. Mar 19 '16 at 00:10