NetSuite – Deleting Records like a pro

September 18, 2018 NetSuite 0

Let’s be honest NetSuite is a great platform, it allows you to do anything you need to run your business successfully, no matter what industry you are; manufacturing, retailing, servicing etc NetSuite has your back.  However, since NetSuite is a proprietary system, the limitations to access the database and some of the system resources are limited to whatever the system was designed to do, the SuiteScript API and SuiteCloud API.

Therefore, you will encounter that one of the shortfalls using NetSuite is the ability to delete records in bulk.  So make sure that your CSV import jobs get tested correctly or you will be spending lots of time clicking, selecting rows and deleting (phew my finger hurts).

Yes, you have the option to delete records by hand; by selecting a cell that supports editing and pressing shift, you should be able to select the rows you want to delete; but this is not deleting records as a pro, this is more like deleting records as a user.

Selecting rows and deleting

This post was created for all of those NetSuite implementers, administrators, users etc, that may require some help deleting those dozens, hundreds or perhaps thousand of unnecessary records. Here is how:

  1. Copy the bellow code into a text editor and save it as mass_del_rec.js
  2. Go to Customization > Scripting > Scripts > New
    1. Upload your script
    2. Select Mass Update
  3. Deploy your script
    1. Select the record you want to delete
    2. Assign the proper permissions
  4. Go to List > > Mass Update > Mass Updates > Custom Mass Updates
    1. Custom Updates > Find the name of the mass update you deployed
    2. Add a criteria as needed; date range, filter by customer etc
    3. Click Preview Update
    4. Verify the data you are deleting is the data you want to delete
    5. Click Perform Mass Update
  5. Done

I have seen this process deleting around two, three thousands of records in less than one hour and around ten thousand in three to five hours.  It works pretty well.

function delRecord(recordType, recordID) {  //record
    try {
        nlapiDeleteRecord(recordType, recordID);
        nlapiLogExecution('debug', 'Deleted ' + recordType + ' Record ID ' + recordID);
    }
    catch (ex) {
        nlapiLogExecution('error', 'Cant delete ' + recordID ' of type ' + recordType, ex.message);
    }
}

I can’t tell you how many times this script has been helpful during an implementation, data migration or some other process, for me or a member of my team.

To delete more complex data like transaction and its related records, contact us.