How to delete multiple records using scheduled jobs

ramyashree
Giga Contributor

Hi All,

I need to delete certain records in a table where a particular field has no value.

I have done it for single record using the below code.

var gr = new GlideRecord('table_name');

gr.addQuery('sys_id','07dbd0ea4f005200634df5a18110c75c');

gr.query();

gr.next();

gr.deleteRecord();

How can i fetch multiple records and delete them using Scheduled jobs.

Thanks,

Ramya

1 ACCEPTED SOLUTION

srinivasthelu
Tera Guru

var gr = new GlideRecord('table_name');


gr.addNullQuery('fieldName');


gr.deleteMultiple();


View solution in original post

7 REPLIES 7

srinivasthelu
Tera Guru

var gr = new GlideRecord('table_name');


gr.addNullQuery('fieldName');


gr.deleteMultiple();


Thanks Srini!!!


I am running this script to delete over 300,000 records in a table. It has been running for about 1.5 hours and has only deleted 20,000 records.



Should it be this slow?