Skip to content

Commit c5ea0ab

Browse files
code_snippet.js
1 parent 7d927da commit c5ea0ab

File tree

1 file changed

+15
-0
lines changed
  • Server-Side Components/Business Rules/Prevent Duplicate CI (Configuration Item) Names

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Business Rule to Block users from saving a CI with a duplicate name but different class
2+
// Before Insert Business Rule on cmdb_ci table
3+
(function executeRule(current, previous /*null when async*/) {
4+
5+
var ci = new GlideRecord('cmdb_ci');
6+
ci.addQuery('name', current.name);
7+
ci.addQuery('sys_id', '!=', current.sys_id);
8+
ci.query();
9+
10+
if (ci.next()) {
11+
gs.addErrorMessage('A Configuration Item with this name already exists!');
12+
current.setAbortAction(true);
13+
}
14+
15+
})(current, previous);

0 commit comments

Comments
 (0)