How to find if there are any duplicate records in any table of ServiceNow?

Not applicable

Hi,

Is there a way to find if there are any duplicate records in ServiceNow table?

Regards

Suman P.

5 REPLIES 5

Dr Atul - LNG
Tera Patron

Hi @Community Alums 

 

In SN, every record saved in specific table only , like Inc/ Change / Prb, for this you can use Task table to search but there is not generic way to find the duplicate records. What is your use case?

Anurag Tripathi
Giga Patron

Hi Dave,

 

I created this function for this same purpose , but haven't used it in some time.

 

gs.print(getDuplicates('<table Name>','<field name>'));

 function getDuplicates(tablename,val)
 {
 var dupRecords = []; var gaDupCheck = new GlideAggregate(tablename);
gaDupCheck.addQuery('active','true');
gaDupCheck.addAggregate('COUNT',val); 
gaDupCheck.addNotNullQuery(val);
gaDupCheck.groupBy(val);
gaDupCheck.addHaving('COUNT', '>', 1);
gaDupCheck.query();
while (gaDupCheck.next()) {
dupRecords.push(gaDupCheck[val].toString());  
}
return dupRecords;
}

 

Hi, 

Just checking to see if this is answered?

Harish Bainsla
Kilo Patron

Hi @Community Alums  check below link

https://www.servicenow.com/community/platform-analytics-articles/get-duplicate-records-from-any-tabl...

If my answer help you please mark helpful and accept solution 

Thanks and Regards 

Harish