- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 08:53 AM
Hi,
We have a import set table (u_reply), currently only 1 week of data maintained on this table. There is an OOTB Scheduled job 'Import Set Deleter' which is removing the data older than 7 days. It calls OOTB script include 'ImportSetCleaner'.
What I need is, I want to have 30 days of data only for the import set table mentioned above. I am having difficulty in modifying the script as I can't change the value of the variable 'daysAgo' present in the script include, because it affects all the import set tables. As per my analysis, we need to add a condition for this table in '_removeData' function but how to set the 30 days?
Can you suggest on this.
Thanks,
Rafi
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2017 07:56 AM
Hi Ankur,
I tried above mentioned code, but it didn't work.
So, I changed the scheduled job script as below and it worked for me. I tested it today only.
However, thanks for your support and help on this.
var gr = new GlideRecord('sys_db_object');
gr.addQuery('super_class.label','=','Import Set Row');
gr.query();
while (gr.next()) {
gs.log('Import Set Tablename is ' + gr.name);
var tblName = gr.name.toString();
var my30DayTable = 'u_cgi_remedy_reply';
if (tblName == my30DayTable)
{
var ic = new ImportSetCleaner(tblName);
// delete import sets and their related import set rows
// that were created more than or equal to 30 days ago
ic.setDaysAgo(30);
ic.clean();
}
else
{
var ic = new ImportSetCleaner(tblName);
// delete import sets and their related import set rows
// that were created more than or equal to 7 days ago
ic.setDaysAgo(7);
ic.clean();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2017 07:56 AM
Hi Ankur,
I tried above mentioned code, but it didn't work.
So, I changed the scheduled job script as below and it worked for me. I tested it today only.
However, thanks for your support and help on this.
var gr = new GlideRecord('sys_db_object');
gr.addQuery('super_class.label','=','Import Set Row');
gr.query();
while (gr.next()) {
gs.log('Import Set Tablename is ' + gr.name);
var tblName = gr.name.toString();
var my30DayTable = 'u_cgi_remedy_reply';
if (tblName == my30DayTable)
{
var ic = new ImportSetCleaner(tblName);
// delete import sets and their related import set rows
// that were created more than or equal to 30 days ago
ic.setDaysAgo(30);
ic.clean();
}
else
{
var ic = new ImportSetCleaner(tblName);
// delete import sets and their related import set rows
// that were created more than or equal to 7 days ago
ic.setDaysAgo(7);
ic.clean();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 11:12 PM
Hi Rafi,
i can see you got the solution for the above req.
i do have kind of a req. can you help me to fix this
Hi Experts,
I have a requirement to cleanup import set data . I know we have OOT scheduled cleaner which we can sent days (default is 7 days)
But my client asking to customize the cleanup like below. Please let me know is it possible if yes how can I do that (Please provide some script )
Import set to be cleaned after 30 days for failed records (skipped/ignored/error)
Import set to be cleaned after 7 days for successful records( insert / update)
Please help on finding the solution .
Thanks in advance .
https://community.servicenow.com/community?id=community_question&sys_id=248bccebdbbcb410981a0b55ca9619e1&view_source=searchResult