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

Community Alums
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 G- LNG
Tera Patron
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?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Anurag Tripathi
Mega Patron
Mega 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;
}

 

-Anurag

Hi, 

Just checking to see if this is answered?

-Anurag

Harish Bainsla
Kilo Patron
Kilo Patron

Hi @Community Alums  check below link

https://www.servicenow.com/community/platform-analytics-articles/get-duplicate-records-from-any-table/ta-p/2304670

If my answer help you please mark helpful and accept solution 

Thanks and Regards 

Harish