- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2017 08:08 AM
Hi - we've been asked to exclude all our HR module data (hr cases, tasks, attachments etc) from our sytem clones
I understand from the documentation that you cannot exclude a table inherited from the task table.
THe queston is whether anyone has found a way to only partially exclude data from the task table (i.e. where task type is HR task or HR case)?
I've just spent the whole day running a background script to delete the data after the clone, and I think this will become more of a time issue hte more data is intered ito our system.
Also, I added a simple exclude on the sys_attchments table which doesn't seem to have worked either..
Has anybody encountered or overcome anything like this?
Solved! Go to Solution.
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2017 09:54 AM
Use the GlideTableCleaner API. It is optimized for speed and performance. For example, here's a piece of code that would delete any incident record created more than 1 second ago. The API also automatically detects and deletes related attachment records.
new GlideTableCleaner('incident', 1, 'sys_created_on').clean();
NOTE: Since this API is not documented it is not officially supported. Beware.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2018 11:10 PM
HI - no way to exclude form the clone, I think this is because you cannot exclude tables that are inherited from the Task table. I've been running a post-clone script to remove cases , tasks, any remaining attachments and metrics.
// clean out HR case and HR task tables
new GlideTableCleaner('hr_case', 1, 'sys_created_on').clean();
new GlideTableCleaner('hr_task', 1, 'sys_created_on').clean();
// delete any remaining attachments
var gratt = new GlideRecord("sys_attachment");
gratt.addQuery('table_name', 'IN', 'hr_case, hr_task');
gratt.query();
gratt.deleteMultiple();
// delete any metrics for HR cases or HR tasks
var grmtr = new GlideRecord("metric_instance");
grmtr.addEncodedQuery('definition.table=hr_case^ORdefinition.table=hr_task');
grmtr.query();