Clone cleanup script not running

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 04:30 AM
To avoid moving a large number of Incidents from our Prod to Test environment during cloning, I tried to use a Clone Cleanup Script, however it never ran.
I verified that the script was good in Test, because since it never ran post-cloning, I had to manually run it in Test.
According to the ServiceNow doc, the cleanup scripts should run automatically after cloning is done.:
https://docs.servicenow.com/bundle/london-platform-administration/page/administer/managing-data/concept/post-clone-cleanup-scripts.html
Does anyone know if there are any properties that need to be set in order to activate the cleanup scripts or know any other reason for it not running?
Yes, I did add the cleanup script on Prod (System Clone => Cleanup Scripts), and we only have one clone target defined, which is Test.
Here is the script:
//Script to delete all incidents older than cut off date
//To change cut off date, adjust the number of days defined in daysOffset
var daysOffset=90;
var cutOffDate = gs.daysAgo(daysOffset);
var deleteCount=0;
gs.log("STARTING DELETING INCIDENT RECORDS");
var gr = new GlideRecord('incident');
gr.addQuery('sys_created_on','<', cutOffDate);
gr.query();
while(gr.next()){
gr.deleteRecord();
deleteCount++;
}
gs.log("FINISHED DELETING " + deleteCount + " INCIDENT RECORDS AS THEY WERE MORE THAN " + daysOffset + " DAYS OLD.");
- Labels:
-
Upgrades and Patches

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 04:43 AM
adding the thread . hope it will help you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 05:03 AM
Thanks, Harshvardhan. I've read the post, but it doesn't really tackle my issue which is non-execution of the script. The post only talks about execution order.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 05:25 AM
I would suggest you open an HI ticket in parallel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2022 10:24 PM
Hi Rolf,
The below link will help you to execute the cleanup script in the target instance.
Note: Make sure you had imported the cleanup script from the source instance.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783212