john_roberts
Mega Guru

Just saw this gem on our internal Live Feed from our resident wizard Mr. Goodliffe. The question on Live was how can I easily locate users with duplicate email addresses. I've always used a GlideAggregate script running in background scripts which really limits it to admins and can't view the results in a list.

Solution:
Create a client callable script include to perform a query for duplicate records, then call that script from a list filter.
More info on GlideAggregate

* Script Include:



/*
Client callable script include used for filtering sys_user lists
to identify duplication email users
name: duplicateEmail
active: true
client callabe: true
*/
function duplicateEmail() {
var xx = new GlideAggregate('sys_user');
xx.addAggregate('COUNT', 'email');
xx.addHaving('COUNT', 'email', '>', '1');
xx.query();
var answer = new Array();
while (xx.next()) {
answer.push(xx.getValue('email'));
}
return answer;
}


* Call the script from a filter. Open the list of users, apply filter Email - is - javascript:duplicateEmail();
* Run it and view the list of users that have duplicate email values
find_real_file.png

27 Comments