Scheduled Job to delete the records

Service Manager
Kilo Guru

Hi All,

Need help to delete the records from custom(delete_Records) table and move those deleted record to another custom table (deleted_records) via scheduled job or (any other efficient way)

I tried below query which is working as expected where records are deleted Only when end date(field) is today(or end date reaches current date)

var gr = new GlideRecord('delete_Records');

gr.addQuery('end_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');

gr.query();

gr.next();

gr.deleteRecord();

 

Thanks

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try 

var gr = new GlideRecord('incident')
gr.addEncodedQuery('end_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'); //to delete all inactive incidents
gr.deleteMultiple();

View solution in original post

4 REPLIES 4

Mike Patel
Tera Sage

try 

var gr = new GlideRecord('incident')
gr.addEncodedQuery('end_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'); //to delete all inactive incidents
gr.deleteMultiple();

I am looking forward to store the deleted records in new custom table

Thanks

There is an audit table which holds the deleted records. The module is under System Definition > Deleted Records. I guess you could just have the custom table have a reference field for the record on the deleted records table, but that's redundant.

Hi,

 

What would be the alternative option to store the deleted records so that when it refer to old incidents, it shouldn't be orphan

Suppose the records got deleted and being referred to closed incident So how can you refer that closed incident to deleted record

Is there any way ?

 

Thanks