How to Fix duplicate numbers issue using background/Fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2023 12:27 PM
Hello Guys,
By running the below script in background scripts, we have identified we have 100+ contract records with duplicate record numbers.
And, For the records that share the same number, I need the more recent record to be renumbered to the next available number by using fix script/background script.
Any help with the code is much appreciated.
Script:
var dupRecords = [];
var gaDupCheck1 = new GlideAggregate('ast_contract');
gaDupCheck1.addAggregate('COUNT','number');
gaDupCheck1.groupBy('number');
gaDupCheck1.addHaving('COUNT', '>', 1);
gaDupCheck1.query();
while (gaDupCheck1.next()) {
dupRecords.push(gaDupCheck1.number.toString() + '\n');
}
gs.print(dupRecords);
Thanks,
Ben.