All, reposting this question of mine to confirm if...
# suitescript
n
All, reposting this question of mine to confirm if someone has any idea / suggestion. I have a general question for the SuiteScript gurus here. The challenge I am facing these days is with regards to different scripts (mostly userevent and Suitelet) trying to make a change on the same record with the same afterSubmit kind of function. For e.g. I know there are at least 4-5 scripts with afterSubmit function deployed on Sales Order. I have been frequently getting these emails from some of these scripts saying "Record has been changed". It's getting more frequent with more scripts and workflows being added in the system. One good thing is these scripts have the try-catch block so it does not crash the page for the user. But still it's really annoying because I know the script sending me these error emails are not executing successfully. Is there any best practice that you guys use when creating the script so you know that it will not interfere with other scripts? I asked NetSuite support if NetSuite has some kind of way to queue up the updates by different scripts - like FIFO or something or based on some logic on the back-end.
s
we have a homemade solution to this. we created our own version of queue manager. It runs off of a custom record where you build the queue and then scheduled scripts run against it to process records. you can also then log if a record has errors and keep retrying automatically until it is successful.
👍🏼 1
n
@sterling_rose Thanks! That is a very good solution actually.
@sterling_rose I am guessing we can use a similar kind of logic for our user event and suitelet scripts?
s
yeah we have actually used it all over the place. So here's a trick... you deploy two scripts for each Queue you have (you only need one record and just name the records to identify them by script) one deployment is scheduled at intervals and another is non-scheduled. Then in your user event you add the record to QM making sure your payload doesn't already exist so you don't waste processing time. Then you also call the scheduled script. This way it will run in real time if it can otherwise it will run at its normal interval.
👍🏼 1