I wrote a suitelet script that allows me to select the record type and submit it to delete all records for that record type. I'm doing this to cleanout my production environment in preparation for go-live. The issue that I'm running into is after the record is deleted, I get an error stating the Record does not exist which throws an error and forces my script to stop. I'm not sure why it's doing that.
Here's the error I'm getting.
Function: productioncleanup
Error: RCRD_DSNT_EXIST
That record does not exist.
Stack Trace: deleterecords(ProductionCleanup.js:92)
productioncleanup(ProductionCleanup.js:52)
My debug logs shows the record was deleted right before and I do notice that when I manually delete a record, it takes me back to the record so it gives me this error.
Here's the part of my code that is deleting all of the records.
function deleterecords(rectype){ var logtitle = 'Deleting record type of ' + rectype; var results = nlapiSearchRecord(rectype,null, null, null); if (results){ nlapiLogExecution('DEBUG', logtitle, 'Results #' + results.length); nlapiLogExecution('DEBUG', logtitle, 'Begin deleting records'); for(var i = 0; results != null && i < results.length; i++){ nlapiDeleteRecord(results[i].getRecordType(),results[i].getId()); nlapiLogExecution('DEBUG', logtitle, 'Deleted record ID ' + results[i].getId()); } }//end results } Any idea what could be wrong? Possibly some setting in my environment that is doing this?