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
‎11-10-2014 02:05 PM
Hello PraveenPadmanabhan
You can create an UI PAGE using following script and include it as a widget/guage in your hompage/Dashboard.
- I've created an UI page to display LIST of duplicate CI's using below code
- <?xml version="1.0" encoding="utf-8" ?>
- <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
- <body>
- <div><b><u>Duplicate CI List</u></b>
- <br />
- <table id="sTable" align="center" style="width:600px">
- <tr bgcolor="#dbe5f1"><th><b>CI Name</b></th><th><b>CI Count</b></th><th><b>Environment</b></th></tr>
- <g2:evaluate jelly="true">
- var ciRec = new GlideAggregate("cmdb_ci");
- ciRec.addAggregate('COUNT', 'name');
- ciRec.groupBy('name');
- ciRec.groupBy('u_environment');
- ciRec.addHaving('COUNT', 'name', '>', '1');
- ciRec.query();
- ciRec;
- </g2:evaluate>
- <j2:while test="$[ciRec.next()]">
- <tr><td>$[ciRec.name]</td><td>$[ciRec.getAggregate('COUNT', 'name')]</td><td>$[ciRec.u_environment]</td></tr>
- </j2:while>
- </table>
- <br />
- </div>
- </body>
- </j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2023 02:56 AM
what is sTable???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 10:09 AM
You can also reuse Amado's script and print out the list of duplicated CI's with a background script:
function getDuplicateCISerialNumbers() {
var answer = new Array();
var i = 0;
var count = new GlideAggregate('cmdb');
count.addNotNullQuery('name');
count.addAggregate('COUNT', 'name');
count.query();
while (count.next()) {
var sn = count.name;
var snCount = count.getAggregate('COUNT', 'name');
if (snCount > 1) {
answer[i++] = new String(sn);
}
}
gs.print("There are " + i);
gs.print(answer);
}
getDuplicateCISerialNumbers()
Then you can copy and paste them into an excel sheet.