Mass search serial numbers that contain text?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi Stephanie,
You could enter these in the search criteria one at a time, like this
or in the filter navigator with an OR between each
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