Remove duplicates in incident metric table Report

poojitha bn
Giga Expert

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:

find_real_file.png

Script Include:

find_real_file.png

Can anyone help me to fix it.

 

1 ACCEPTED SOLUTION

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.

View solution in original post

13 REPLIES 13

Ankur Sharma
Tera Guru

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.

Hi Ankur,

I have tried the same but still duplicates are coming.

Any other idea ????

 

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.

Hi Ankur,

I tried but still duplicates exist.