Mass search serial numbers that contain text?

StephanieH04070
Kilo Explorer

Hello, I need to search the hardware table for 100s of serial numbers but only part of the serial numbers is given.  Is there a way to mass search serial numbers that contain xyz?  For example, I am given 1309531, 131952 and 1420341 but the database might have 1 or 2 leading zeros so I would have to search each serial number with " * " in front of it.  Or maybe there is a report I can run similar to this type of search?

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Hi Stephanie,

You could enter these in the search criteria one at a time, like this

BradBowman_0-1765993514419.png

or in the filter navigator with an OR between each

BradBowman_1-1765993594057.png

If your search criteria will contain hundreds of values, it would be easiest to find the records via a Fix Script like this:

var snArr = ['1309531', '131952']; //paste in a list from Excel...
var arrayUtil = new ArrayUtil();
var hwArr = [];
var hw = new GlideRecord('alm_hardware');
hw.query();
while (hw.next()) {
	var sn = parseInt(hw.serial_number,10);
	if (arrayUtil.contains(snArr, sn)) { //serial_number of this record found in the list
        hwArr.push(hw.sys_id.toString()); //or use serial_number, asset_tag,...
	}
 }
 gs.print(hwArr.join(','));

Then you can copy the entire value from the script dialog window and paste it into a list view filter to get a list of the actual hardware records

BradBowman_2-1765995322350.png