We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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 G- 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?

*************************************************************************************************************
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/dratulgrover [ Connect for 1-1 Session]

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

Anurag Tripathi
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

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