How to run de-duplication task in bulk?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 05:21 PM
We have a thousands of CMDB de-duplication tasks and needed a way to automate it.
Please suggest a way to do so?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 06:07 PM
You could write a script that sorts by the field(s) that indicate a duplicate task, then loop through the entire set.
var gr = new GlideRecord('task');
gr.addEncodedQuery('parentISEMPTY'); //Avoid deleting tasks that have a parent reference to another record
gr.orderBy('sys_class_name');
gr.orderBy('short_description'); //Indicates second sort by column
gr.query();
gr.next();
var previousKey = gr.sys_class_name + ';' + gr.short_description;
while (gr.next()) {
var key = gr.sys_class_name + ';' + gr.short_description;
if (previousKey = key) {
//duplicate
gr.deleteRecord();
}
else {
//not duplicate
previousKey = key;
}
}
Notes:
* I haven't tested this script but it illustrates the approach
* I'm not sure if a set of duplicate records will have one Task with a Parent value and the other is null. But I provide at least a way you may be able to prevent deleting tasks with references to other records.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 07:51 PM
Hi Erik,
It is to reconcile the CMDB CI de-duplication task and how can I run them automatically.
Sorry if you misunderstood the question

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 06:11 PM
I should add, you could run this from the "Scripts - Background" form. You could also create a script include and call it from a scheduled job.
Note: I'm not sure why you would have duplicate tasks, but resolving this at the root cause is key.
If any of this was helpful, please indicate in this thread. Thanks.