Tuesday, November 27, 2018

Sample script utilizing nlapiYieldScript API

 

do{  
      var searchresults = nlapiSearchRecord('salesorder', 5, filter, null);

      if(searchresults){
            processResults(searchresults);
      }
      if (context.getRemainingUsage() <= 100){
            var stateMain = nlapiYieldScript(); 
            if( stateMain.status == 'FAILURE'){ 
                  nlapiLogExecution("debug","Failed to yield script (do-while), exiting: Reason = "+ stateMain.reason + " / Size = "+ stateMain.size); 
                  throw "Failed to yield script"; 
            } 
            else if ( stateMain.status == 'RESUME' ){ 
                  nlapiLogExecution("debug", "Resuming script (do-while) because of " + stateMain.reason+". Size = "+ stateMain.size); 
            } 
      }
}
while(searchresults);


DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.

NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchant-ability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment