Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to prevent automatic record deletion in the import set table

Yuki21
Tera Expert

Is there a way to prevent records in the import set table from being deleted?

By default, the cleanup schedule removes it every 7 days.

Instead of not deleting records in all import set tables, I want to prevent records from being deleted in specific import set tables.

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

WARNING: making a mistake customizing a cleanup script may delete tables/records that was not intended. Take a backup and conduct tests to make sure to avoid unexpected behaviors. I take no responsibility for any lost.

The class that's actually cleaning up the tables is Scriplet Include named "ImportSetCleaner".

I haven't tested this and not 100% sure but there's a function "_getScriptedImportSetTables() that seems be querying the sys_db_object table to get import set table names to delete.

Customizing "ImportSetCleaner" class to skip tables that needs to be retained may solve the problem.

I won't directly modify the ImportSetCleaner class but clone it.

The job using this class is "Import Set Deleter" (System Import Sets >L Scheduled Cleanup". Change "var ic = new ImportSetCleaner();" to point to the customized class.

 

View solution in original post

4 REPLIES 4

Maik Skoddow
Tera Patron
Tera Patron

Hi @Yuki 

I didn't find a way to prevent specific tables to be excluded from data cleanup, but the overall configuration for the cleanup job can be found and configured as follows:

find_real_file.png

Let me know if you have any further questions.

Kind regards
Maik

It was already the same setting.
Please let me know if your perception is different.

 

find_real_file.png

Hitoshi Ozawa
Giga Sage
Giga Sage

WARNING: making a mistake customizing a cleanup script may delete tables/records that was not intended. Take a backup and conduct tests to make sure to avoid unexpected behaviors. I take no responsibility for any lost.

The class that's actually cleaning up the tables is Scriplet Include named "ImportSetCleaner".

I haven't tested this and not 100% sure but there's a function "_getScriptedImportSetTables() that seems be querying the sys_db_object table to get import set table names to delete.

Customizing "ImportSetCleaner" class to skip tables that needs to be retained may solve the problem.

I won't directly modify the ImportSetCleaner class but clone it.

The job using this class is "Import Set Deleter" (System Import Sets >L Scheduled Cleanup". Change "var ic = new ImportSetCleaner();" to point to the customized class.

 

This section seems to be selecting files to process.

find_real_file.png