Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 12:15 AM
Have a look at https://www.servicenow.com/community/platform-analytics-articles/get-duplicate-records-from-any-tabl.... This way you can get the existing duplicates out of the system.
If the index is not being created, because it says non-unique, there must be a duplicate somewhere.
As background script, delivering something like :
*** Script: INC0008111,INC0009009
gs.info(getDuplicates('incident','number')); //your table and fieldname
function getDuplicates(table, field) {
var dupRecords = [];
var gaDupCheck = new GlideAggregate(table);
gaDupCheck.addAggregate('COUNT', field);
gaDupCheck.addNotNullQuery(field);
gaDupCheck.groupBy(field);
gaDupCheck.addHaving('COUNT', '>', 1);
gaDupCheck.query();
while (gaDupCheck.next()) {
dupRecords.push(gaDupCheck[field].toString());
}
return dupRecords;
}