Find duplicate records in ServiceNow

Find duplicate records using GlideAggregate and groupBy

var importGR = new GlideAggregate('u_import');
importGR.addAggregate('COUNT', 'u_number');
importGR.addNotNullQuery('u_number');
importGR.groupBy('u_number');
importGR.addHaving('COUNT', '>', 1);
importGR.query();
while (importGR.next()) {
  gs.log(importGR.u_number);
}

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Interview Question on Ruby on Rails