I tried following a help document for rescheduling a scheduled script based on coming close to execution limit. However, it isn't working and I'm getting the SSS_USAGE_LIMIT_EXCEEDED. It doesn't seem to affect anything, as the script will just run again 15 minutes later, but I'm annoyed that the code doesn't work as intended. Also, I'm not seeing anything in the Debug log. Any help is appreciated for this casual coder. I'm basically, trying to run a scheduled script to update invoices based on a search to set the product class based on a field of the end user customer.
function updateProductClass( type ) { //only execute when run from the scheduler if ( type != 'scheduled' && type != 'skipped' ) return; var context = nlapiGetContext(); var filters = new Array(); //filters[0] = new nlobjSearchFilter( 'mainline', null, 'is', 'T' ); var searchresults = nlapiSearchRecord( 'invoice', 'customsearch642', filters, null ); for ( var i = 0; searchresults != null && i < searchresults.length; i++ ) { var record = nlapiLoadRecord(searchresults[i].getRecordType(),searchresults[i].getId() ); var EndUser = record.getFieldValue('custbody_end_user'); if (EndUser != null) { var stProductClass = nlapiLookupField('customer',EndUser,'custentity6'); } else { var stProductClass = 77 } record.setFieldValue('class',stProductClass); nlapiSubmitRecord(record); debug(record.getFieldValue('internalid')); if ( context.getRemainingUsage() <= 0 && (i+1) < searchresults.length ) { var status = nlapiScheduleScript(context.getScriptId(), context.getDeploymentId()) if ( status == 'QUEUED' ) break; } } }