We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

VaranAwesomenow
Mega Sage

Below script gives unique list of vendor and manufacturer names

var vendorHash = {};
var ManufacturerHash = {};
var grCi = new GlideRecord('cmdb_ci');
grCi.query();
while(grCi.next()) {
ManufacturerHash[grCi.getDisplayValue('manufacturer')] = 1;
vendorHash[grCi.getDisplayValue('vendor')] = 1;
}
printHash(ManufacturerHash, 'Manufacturer');
printHash(vendorHash, 'Vendor');

function printHash(hashArray, Name) {
for (var k in hashArray) {
// use hasOwnProperty to filter out keys from the Object.prototype
if (hashArray.hasOwnProperty(k)) {
gs.print( Name + "|"+ k + "|"+ hashArray[k]);
}
}
}

var vendorHash = {};
var ManufacturerHash = {};
var grCi = new GlideRecord('cmdb_ci');
grCi.query();
while(grCi.next()) {
ManufacturerHash[grCi.getDisplayValue('manufacturer')] = 1;
vendorHash[grCi.getDisplayValue('vendor')] = 1;
}
printHash(ManufacturerHash, 'Manufacturer');
printHash(vendorHash, 'Vendor');

function printHash(hashArray, Name) {
for (var k in hashArray) {
// use hasOwnProperty to filter out keys from the Object.prototype
if (hashArray.hasOwnProperty(k)) {
gs.print( Name + "|"+ k + "|"+ hashArray[k]);
}
}
}

 

Version history
Last update:
‎01-12-2021 06:27 AM
Updated by: