Commit 350b97a
authored
Create DuplicateCIDetectorScriptInclude.js
var DuplicateCIDetector = Class.create();
DuplicateCIDetector.prototype = {
initialize: function() {},
findDuplicates: function(ciName, serialNumber, assetTag, sysId) {
var duplicates = [];
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('active', true);
// Basic name match (case-insensitive)
if (ciName) {
gr.addQuery('name', 'LIKE', ciName);
}
// Optional matching by serial or asset tag
if (serialNumber) {
gr.addOrCondition('serial_number', serialNumber);
}
if (assetTag) {
gr.addOrCondition('asset_tag', assetTag);
}
if (sysId)
gr.addQuery('sys_id', '!=', sysId); // ignore current record
gr.query();
while (gr.next()) {
duplicates.push({
name: gr.getValue('name'),
serial_number: gr.getValue('serial_number'),
asset_tag: gr.getValue('asset_tag'),
sys_id: gr.getUniqueValue()
});
}
return duplicates;
},
type: 'DuplicateCIDetector'
};1 parent 11936d4 commit 350b97a
File tree
1 file changed
+40
-0
lines changed- Server-Side Components/Business Rules/Duplicate CI Detection for ServiceNow
1 file changed
+40
-0
lines changedLines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments