- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 08:37 AM
Hello Team,
We have a custom Table X and for some reason the numbering has started creating duplication at the insert of the record. I need help identifying duplicate records. The number of records are huge 900K+ so Group by will take forever.
If we can printout the duplicate records via script, that would be good. After that we can work on those duplicates.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 08:55 AM - edited 10-28-2024 08:58 AM
Try this in the Background Scripts:
gs.info(getDuplicateValues(<table>, <field>));
function getDuplicateValues(table, field){
var dupValues = [];
var ga = new GlideAggregate(table);
ga.addAggregate('COUNT', field);
ga.addNotNullQuery(field);
ga.groupBy(field);
ga.addHaving('COUNT', '>', 1);
ga.query();
while (ga.next()) {
dupValues.push(ga[field].toString());
}
return dupValues;
}
****NOTE: It might take a lot of time to complete the query and might even get you session resources locked for this operation. So I strictly suggest you to run this in the possible lower instance where the criticality is low. ****
Reference: Get Duplicate Records from any table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 07:40 PM
Add this line before ga.query() function call:
ga.addEncodedQuery(“active=true”)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 07:44 PM
Thanks @Ravi Peddineni I will try out.