Info: HTN-104
As we know, the governance limit for Schedule script is 10000 & crossing this will result in execution failure.
Normally, we reschedule scripts to overcome these conditions. But what about in the case where we perform loops that search huge records & update based on the given range.
Example situation:
Consider 150 customers are available in NetSuite along with 13 categories.
- Usage limit seen → 1 customer x 1 category = 16 (if No calculation is performed – Based on task criteria)
else, 26 is required instead of 16.
ie, for a single customer, max governance = 26 * 13 = 338. - Recently customers were taken by 50 Range each & this will cross 10000 limits & neglect the Rescheduling condition. ( 50 * [26 * 13] ) = 16900. This results in the failure of script.
- In order to overcome this, we have to reduce the Start & End ranges so as to limit the Governance by 10K.
(Instead of 50, we reduced the range to 29.)
Note:
The Usage limit depends upon how we retrieve the specific data & varies based on the conditions given.
A best practice is to check the remaining limit after every set of execution. An example for the same is added below.
var usagelimit = runtime.getCurrentScript().getRemainingUsage();
log.debug("Remaining usage limit",usagelimit);