Background script to delete records

CV1
Tera Contributor

Hi All,

Have a requirement to delete empty rows from sys_user table. There are massive no of empty records based on conditions(encoded query)and when trying to delete its hanging.

 

Please suggest script to delete say 1000 or 2000 records from the list and then run the script again to delete next batch.

 

TIA 

 

 

6 REPLIES 6

chetanb
Tera Guru

Hello @CV1 

 

I would suggest to use glidemultipledelete API as there are no requirement to delete associated records and hence this method is super fast.

 

var md = new GlideMultipleDelete("sys_user");

md.addQueryString('Query');

md.execute();

gs.info('Records deleted successfully');

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Regards,

CB

Ankur Bawiskar
Tera Patron
Tera Patron

@CV1 

try to use setLimit() and delete in chunks

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader