Skip to content

Instantly share code, notes, and snippets.

@harrisitservices
Last active February 6, 2018 18:57
Show Gist options
  • Save harrisitservices/0f019a5d9fa0695554b3a36946c602b7 to your computer and use it in GitHub Desktop.
Save harrisitservices/0f019a5d9fa0695554b3a36946c602b7 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