- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:25 AM
Good Afternoon,
I have been working for the last day trying to figure out how to make a filter based on JavaScript for a report. Here is what I am trying to do. Search all CI's (cmdb_ci) table, and look for duplicate IP Addresses. I used a Multi Pivot Table to get this report, and of course the performance was hindered in my instance - so this approach is not optimal. I than wanted to filter out those rows that just had a single instance of an IP Address.
Here is the javascript I attempted to use.
var GetDupesTake2 = Class.create();
GetDupesTake2.prototype = {
initialize: function() {
},
GetDupesTake2: function(tablename, dupefield) {
var q = new GlideAggregate(tablename);
q.addAggregate('COUNT', dupefield); //aggregate to count values in whatever field is passed as dupeField
q.addHaving('COUNT', dupefield, '>', '1');
q.query();
var listOfDupes = []; //build array to push the results into
while (q.next()) {
listOfDupes.push(q.getValue(dupefield)); //Push the value of the dupe field to the array
jslog('I did something');
}
return listOfDupes;
},
type: 'GetDupesTake2'
};
for the Filter I had it set to
IP Address is one of javascript:GetDupesTake2('cmdb_ci','ip_address);
Can someone please point me in the right direction? The above is not working.
Thanks in Advance!
Jason
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 01:43 PM
Code looks right. Make sure the script include is client callable. From the script include code I don't think it is checked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:35 AM
Are you trying to group CI's by IP address?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:42 AM
I am trying to do it by the whole table.
But I want it displayed by Class
so
Servers | Computers | NetworkGear | Total | |
IP Address 1 | 1 | 0 | 1 | 2 |
IP Address 2 | 1 | 0 | 0 | 1 |
IP Address 3 | 1 | 1 | 1 | 3 |
I want to say, if the total is One - filter it out of the report.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:53 AM
I want to say if the total,or count is 1, ignore the record.