deletion of archive records using a script

Tom Kerman
Tera Contributor

We have a customer who would like to delete archive records (e.g. ar_incident). They have different requirements for deletion based on properties of the incident (e.g company, priority etc) however destroy rules seem very restrictive in terms of defining which records to delete at a given time, so these are not appropriate for this use case.

My initial thought was to use a script to delete thes records, but my attempt to use GlideRecord.deleteRecord() to acomplish this failed. No error given, but the record was not deleted either.

So my question is this: Is there any way to delete archive records other than by using destroy rules?

Many thanks

1 ACCEPTED SOLUTION

No, unfortunately you can only use condition builder

Best Regards
Aman Kumar

View solution in original post

4 REPLIES 4

Tom Sienkiewicz
Mega Sage

You could try to flush those records using the Table Cleaner (Administration > Table Cleanup).

The cleaner runs in regular intervals and you need to set the "Age" parameter accordingly, to ensure only those records are considered, on top, you can add additional conditions.

Aman Kumar S
Kilo Patron

Hey,

A/C to SN support docs:

In order to ensure that all traces of an archived record are purged from the instance ServiceNow recommends the creation of a Table Cleaner (sys_auto_flush) or a custom script job to complete the required clean up based upon your specific requirements

Table cleaner

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Thanks Aman,

This is what the customer has decided to implement. Is it possible to script this in any way?

Tom

No, unfortunately you can only use condition builder

Best Regards
Aman Kumar