Background Script to delete records:

Follow the steps to delete records using Nackground script.

  • Navigate to System Defnition -> Scripts – Background
  • Script:
var inc = new GlideRecord('incident'); //Table Name
inc.addQuery("active","false"); // Filter
inc.query();
while(inc.next()){
inc.setWorkflow(false);
count++;
inc.deleteRecord(); // Delete records
}
gs.print('No. of records deleted = '+count);