Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nancystodd/4b0d71f1971589f1936a5c558941b109 to your computer and use it in GitHub Desktop.
Save nancystodd/4b0d71f1971589f1936a5c558941b109 to your computer and use it in GitHub Desktop.
ServiceNow - Search Field for Duplicate Values

Search Field for Duplicate Values

This script uses GlideAggregate to search a field on a table for duplicate values. It then returns the value with duplicates in an array.

var xx = new GlideAggregate('table');  
xx.addAggregate('COUNT', 'field');  
xx.addHaving('COUNT', 'field', '>', '1');  
xx.query();  
var answer = [];  
while (xx.next()) {  
    answer.push(xx.getValue('field'));  
}  
return answer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment