
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 04:50 AM
Hi Experts,
I have to remove duplicates in Incident_metric table report.
Currently I am trying to remove using script include but I couldn't achieve it. Can anybody help me doing this.
Report:
Script Include:
Can anyone help me to fix it.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2019 03:13 AM
Hi Poojitha,
The above code will not work as it returns incident number which is same for duplicate records so the report will display duplicate records. As per your screenshot, if the function returns 'FVSD_2337' then report will still display all three records as they all satisfy the condition.
So you need to return unique value like sys_id of one of the duplicate so the report doesn't display the other duplicate.
Let me know if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 05:31 AM
Hi Poojitha,
Can you please change the code at line 17 in your script include to the following:
return noDuplicates.join(",");
Let me know if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 05:39 AM
Hi Ankur,
I have tried the same but still duplicates are coming.
Any other idea ????

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 05:51 AM
Can you please try the following. Replace encodedQueryStr with your encoded query.
var arr = [];
var gr = new GlideAggregate('incident_metric');
gr.addEncodedQuery(encodedQueryStr);
gr.addAggregate('COUNT', 'inc_number');
gr.addNotNullQuery('inc_number');
gr.groupBy('inc_number');
gr.query();
while(gr.next()){
arr.push(gr.getValue("inc_number"));
}
return arr.join(",");
Let me know if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 05:55 AM
Hi Ankur,
I tried but still duplicates exist.