Skip to content

Commit d21c50d

Browse files
Hactober fest 2025 (2nd pull request) (#2501)
* code_snippet.js * README.md * Add files via upload * code_snippets.js This Script block users from saving a CI with a duplicate name but different class. * README.md
1 parent 80fea35 commit d21c50d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This Script under code_snippet.js block users from saving a CI with a duplicate name but different class.
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)