“I have some records in a table which are duplicates. In this case, I can only identify “duplicate records” by whether several fields are identical; not just one. For example, let’s say I want to identify Incidents where the Short description, Assignment group, and Assigned to user are all the same. If only one or two of those fields match, but one of them is different, then the records are not duplicates. The’re only duplicates if all three fields are the same.
Is there any way to accomplish this with a script? Maybe by using
GlideAggregate
?”
Thanks for your question, and indeed, there is a way to identify duplicate records based on multiple matching fields in a script in ServiceNow!
At first glance, you might think that the GlideAggregate APIs do not support any direct mechanism by which to identify duplicate records across multiple identical fields. However, there is a way!
By getting just a smidge clever, we can call the .groupBy()
API method multiple times, in combination with the .addAggregate()
and .addHaving()
methods, to accomplish our goal of identifying duplicate records with more than one field that are identical.
Read on to learn more!
Read more