So here's a fun story: I've been working on a piece of scripting to calculate a freight charge on a specific sales order attributed to a shipping bill and attach it to a custom field on the sales order. This has involved a large number of shenanigans, including creating a direct relationship between a sales order and a bill via a drop down list on the sales order, the creation of a new form to handle bills with attributed bills of lading separate from other bills, and a rejected SQL search that got way too complicated for its own good.
After a week or so of banging on my keyboard, I managed to pull together a script that does what I need. It checks for any bills or sales orders that have been modified since yesterday, and then calculates a freight charge for either the single sales order pulled or else every sales order attributed to a given bill. Of course, in order to calculate the freight charge for a single instance, you have to grab the total amount from the bill, grab the combined quantity from all of the related sales orders, divide the amount by the total quantity, and then finally multiply said "amount-per-unit" by the amount on the individual sales order before being able to populate it.
Naturally, this involves a lot of searching with nlapiSearchRecord, and we found that it only takes a few modified bills and sales orders to hit the scripting limit. At this point I am working to see if I can optimize the code, but unfortunately I don't think I'll be able to cut out the huge amount of searching that is needed.
I've been doing a bit of research on my own, and I found the following thread on here:
https://usergroup.netsuite.com/users/showthread.php?t=29335
which discusses monitoring script usage and creating a new instance of the script as the limit is approached. I could not find a code example of doing this, so if someone could point me in the right direction it would be appreciated.
I've got some ideas of my own in regards to optimization, but if anyone has anything off the top of their heads or, even better, a smart idea on how to circumvent this SuiteScript mess altogether, I'm all ears. Better to find out about the easy way three weeks later than not at all.