Hi all! From performance point of view, does it ma...
# suitescript
m
Hi all! From performance point of view, does it matter if I have many before submit scripts in one record instead I would have all the before submit functionality in one script?
n
In theory, there should be a performance improvement, but I think it would be microseconds. When working with NetSuite, the unit of measurement is seconds, So, it's up to you if you want to trade off your 'Separation of concerns' (Separate Scripts) for a few microseconds.
m
Ok, thanks! 🙂
o
There is minimal overhead from executing lots of seperate functions. It's there, but it's not a huge impact. That being said, depending on the content of those scripts, you may see significant performance increase if you consolidate the logic. Just a random illustrative example: let's say you have 2 distinct scripts that both cycle through all line items of the transaction - you would likely gain performance if you merged your logic and only cycled through line items once.
👍🏻 1
n
might also want to factor in NS's own comment about the number of UE's you have against a record: "You can specify the order in which user event scripts are executed for this scripted record. Note that deploying too many user event scripts of the same trigger type may impact performance. NetSuite recommends deploying no more than 10 scripts of the same trigger type, however, all scripts set to Deployed will execute." (lifted from the scripted records details for a record)
👍🏻 1
a
One script will be substantially faster (depending on the number of before submit scripts). Why? Each UserEvent execution requires it's own context and scope which adds an overhead to the execution
👍🏻 4
d
(I think we have 40 user event scripts on the sales order)
a
Uh, then I think merging them all could substantially speed things up
you could give it a try!
d
nah man, there's like 8 years of collective business logic in there, one sneeze and the house of cards collapses
n
Try it in Sandbox, Create libraries for each and then keep calling them one by one In one common function. I won't suggest you do all the 40 in one script or even in one go, just start with 2-3 scripts at one time and you should be fine. I have done this before. We had similar amount of scripts and we reduced them to 27. We did kept some of the scripts discreet from others as they were complex and merging them was "risky".
d
yeah that'd be the way to go. we've got bunch of 1.0 and 2.0 scripts. then, quite a few scripts are loading and saving the sales order, of course it'd be nice to consolidate those.