HOW TO OVERCOME GOVERNANCE LIMIT IN SCHEDULE SCRIPT?

Schedule script has a governance limit of 10000 units. In many situations, schedule script is used for processing huge amount of data and this might take more than 10000 units. To overcome this problem, Netsuite provides the api's nlapiSetRecoveryPoint() and nlapiYieldScript(). This creates a recovery point and re-executes the schedule script from where it left and its governance units are also reset. It can create a recovery point even inside a for or while loop. nlapiSetRecoveryPoint() consumes 100 units. The below code explains how to use these api's

if(nlapiGetContext().getRemainingUsage()<300)
{
 
                     nlapiSetRecoveryPoint();
                     nlapiYieldScript();
}

Put the above code at a point where it can check the remaining usage after each iteration of your code.

Email : info@smilingcoders.com

Facebook page : https://www.facebook.com/Netsuite-Academy-1591053827660082/

Comments

Popular posts from this blog

Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite

Understand Core Technology behind SuiteScript 2.0

HOW TO SET SUBLIST SUB RECORD VALUES IN SUITE SCRIPT 1.0 AND 2.0