Deleting old records from import set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2017 09:40 AM
Hi All,
I have a requirement where I need to delete the old records from the Import set before Inserting new records into the import set.
How can i do that ??
Thanks,
SD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2017 10:59 AM
Hi Earl,
Could you help me with sample script?
Thanks,
SD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2017 11:49 AM
The script mentioned above by Saketh should work just fine. All you have to do is change the table name to be your import set target table and make a fix script out of it.
To reiterate some of the comments mentioned above, you do this at your own risk. If you absolutely know that this is what you need to do then go for it. But there are mechanisms in place to handle many imports in a single day, and in close time proximity. So the need to do what you're suggesting is still in question. Best of luck.
Earl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2018 05:06 AM
For the benefit of others who might come across this old post.
On my import scheduled job I added a post-execute script to clean up all but the most recent 7 import sets (which in turn cleans up the import table).
(function() {
// remove all processed import sets more than 7 iterations old
var gr = new GlideRecord('sys_import_set');
gr.addQuery('data_source', data_source.sys_id);
gr.addQuery('state', 'processed');
gr.orderByDesc('sys_created_on');
gr.query();
var i = 0;
while(gr.next()) {
if (++i > 7) {
gr.deleteRecord();
}
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2019 12:58 PM
This is not functional. Import data needs to be cleared before the next import, or import needs to coalesce just like a transform. I can not find options for either of these, so my import table becomes an absolute bloated mess with questionable results and degrading performance. How can this be corrected?