Hey all - we are randomly getting an error when su...
# suitescript
j
Hey all - we are randomly getting an error when submitting an external form that is "Script Execution Usage Limit Exceeded" - nothing has changed on the external form in months, and we have never seen this error. Can someone please help?
e
What does that form do exactly?
j
It creates a customer, address record, and then a project record under that customer and fills in some of, not all, of the fields associated to that project.
e
So although nothing has changed with the form, has anything changed with scripts attached to records that the form creates? i.e. Have you added any sort of scripts to your Customer Records / Project Records?
j
Nope, not that I know of at least.
What exactly cause this?
A timeout of what script?
I guess a better question is where do I go in Netsuite to look at the logs?
e
it's actually quite tough to find the exact culprit - that error is usually triggered when scripts attached to records you're creating are "doing too much"
j
How would I at least find the script attached to the form?
e
If you've never need it before, it's very likely that some scripts were added or changed that are running on your Customer Record or Project Record
Customization > Scripting > Scripted Records
Then look through the scripts under Customer and Project
j
customer - 13 scripts, 8 workflows project - 16 scripts, 22 workflows
e
Since thats a form, it's likely User Event scripts that are causing issues
j
message has been deleted
message has been deleted
now how would I use process of elimination to find out which script is causing the error?
e
Id first check with different script owners to see if they've made changes lately
j
Fudge
They aren't available right now and we have 3 projects to submit, fml
Is there really no execution log that I can pull that would at least show me at what point of the form execution it's getting held up on?
e
are you able to enter them manually through the UI?
j
What do you mean
e
i.e. Create the Customer then Create the Project record in NetSuite
instead of using that form
j
Yeah, I just tried. and literally gave me the same error WTF
Only tried to create a customer too, wow
I guess that narrows it down to being a customer related user event script?
Wow I fixed it
Literally went to setup > general preferences
And switch the API from 2.1 to 2.0
How on earth was that the cause of the error?
j
So each function call has an associated “cost”, one script can only costs <x> number of points in total (I think it’s 1000 for most script types). Sometimes if you have too much happening (and/or getting triggered) from one script, it will hit the limit. You should have been able to see the place where it broke in code by looking at the overall Script Execution Logs page under the Customization tab.
Often it’ll be a runaway loop or just something that runs on <n> things and <n> is too high in some cases. We hit this for example on a particular transaction that had many, many items.
If you’re wanting to track how much “room” have have left before hitting the execution limit, you can log it (but remember, logging also probably “uses up” some of your cost).
Copy code
var my_script = runtime.getCurrentScript();


// then at various points in your script
log.debug({title: 'Remaining Usage', details: my_script.getRemainingUsage()});
🙌 1