Finding Duplicate Records in CMDB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 12:18 PM
Hi All, I have implemented script to find out the duplicate records with the help of serial number in background scripts. Please check the below script:
gatherDupes();
function gatherDupes() {
var gr = new GlideAggregate('cmdb_ci_computer');
gr.addAggregate('COUNT', 'serial_number');
gr.groupBy('serial_number');
gr.addHaving('COUNT', '>', 1);
gr.query();
var dupSerialNumber = [];
gs.log("The following " + gr.getRowCount() + " CIs has duplicates based on serial number field...");
while (gr.next()) {
gs.log("Duplicates: " + gr.getAggregate('COUNT', 'serial_number') + " => " + gr.serial_number);
}
}
Now that i was able to find the duplicate records. This is how it looks: after running in background
*** Script: The following 4 CIs has duplicates based on serial number field...
*** Script: Duplicates: 106 =>
*** Script: Duplicates: 2 => 56WHL71
*** Script: Duplicates: 2 => AEX5635Z0001AC
*** Script: Duplicates: 16 => L3BB911
If serial number 56WHL71 has 2 Duplicates . Now the requirement is what is the discovery source of these both?
Now there is a Integration with BMC discovery. so, one discovery source should be BMC DIscovery and other should be empty or unknown as the record is created manually.
What should i add in the above script so that i get the discovery source of these 2 serial number.
It should print like 1. serial number (56WHL71) is with discovery source BMC discovery and
2. serial number (56WHL71) is with discovery source unknown or empty or system.
please advise.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 01:10 PM
Hi,
Please refer to this link and see if something like this will work in your scenerio
GlideAggregate: grouping by multiple columns
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***