Craig Jones3
Giga Contributor

I have created a script which I used to show us which companies we had duplicate records for, thought it might be useful for others so posting it on here. It's designed to run as a background script.

In the instance I was running this on, they were using the vendor mangement module, and had used the normalisation field also. 

The script will show you which non vendor company records you have more than one normalised value for. 

var count = new GlideAggregate('core_company');
count.addQuery('canonical','!=','FALSE'); //used to filter out non normalised values
count.addQuery('vendor','false'); //used to filter out vendor records
count.addAggregate('COUNT','name');
count.query();
while(count.next()){
    var name = count.name;
    var nameCount = count.getAggregate('COUNT','name');
    if(nameCount > 1){
    gs .info(name + ' has ' + nameCount + ' entries');
    }
}

Hope this helps someone at some point!

Version history
Last update:
‎01-28-2020 07:29 AM
Updated by: