logo

NJP

A script to show you if you have duplicate company records

Import · Jan 28, 2020 · article

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!

View original source

https://www.servicenow.com/community/itsm-articles/a-script-to-show-you-if-you-have-duplicate-company-records/ta-p/2311987