How to find the duplicate CIs in a table using Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2012 04:55 AM
Hi All,
I want to know whether any duplicate entries(CIs) are there in my table. I want to run a query which shows me only the duplicate entries. Is there a way to create a report with only the duplicate entries.
Please let me know whether i can create a script to fetch the duplicate entries from the tables. If yes, where to deploy this script to generate a report which only contains the duplicate entries.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2012 08:19 AM
I haven't had much of reporting to be done on duplicates,but yes as an Admin i wanted to know if there were any duplicates . And for all kinds of gathering the duplicates, there is this perfect link,which will give the duplicates(you would want to customize the code in there). I haven't tried to write it to a file but i feel you can give it a shot from a business rule.
Duplicate record
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2012 11:50 AM
Abhiram,
Thanks for the update. I do not know about the background scripts. Can you explain me how to create a background script and where to run that script in Service Now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2012 06:01 PM
When the post means a background script, it doesn't literally mean a background script.I usually use it as display business rule.
You can also use scripts-Background for this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2014 09:59 AM
Hi Praveen,
I have created a list that displays CIs with duplicate serial numbers. You need to create a client-callable business rule as follows:
Name: getDuplicateSerialNumbers
Table: Global
Client callable: yes
Active: yes
Script:
function getDuplicateCISerialNumbers() {
var answer = new Array();
var i = 0;
var count = new GlideAggregate('cmdb_ci');
count.addNotNullQuery('serial_number');
count.addAggregate('COUNT', 'serial_number');
count.query();
while (count.next()) {
var sn = count.serial_number;
var snCount = count.getAggregate('COUNT', 'serial_number');
if (snCount > 1) {
answer[i++] = new String(sn);
}
}
return answer;
}
You can add more functions to this business rule to look for duplicates on other key fields .
Next step is to create a module as follows:
Title: Duplicate Serial Numbers
Link type: URL (from arguments)
Arguments: cmdb_ci_hardware_list.do?sysparm_query=name=javascript:getDuplicateCISerialNumbers^EQGROUPBYserial_number
This won't give you a report but a grouped list, which can be exported to Excel.
Let me know if you have any questions.
/Amado