Skip to content

Commit 244e706

Browse files
Create relationship.js
Automatic Relationship Builder on CI Update
1 parent c0877b3 commit 244e706

File tree

1 file changed

+15
-0
lines changed
  • Server-Side Components/Business Rules/Automatic Relationship Builder

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+
/* Scenario :
2+
When a new CI (like an Application Server) is discovered or updated, automatically create “Runs on”, “Depends on”,
3+
or “Connected to” relationships based on specific patterns.*/
4+
5+
// Table: cmdb_ci_appl | BR: after insert/update
6+
(function executeRule(current, previous) {
7+
if (current.u_host) {
8+
var rel = new GlideRecord('cmdb_rel_ci');
9+
rel.initialize();
10+
rel.parent = current.u_host; // parent = server
11+
rel.child = current.sys_id; // child = application
12+
rel.type = 'Runs on::Runs'; // relationship type
13+
rel.insert();
14+
}
15+
})(current, previous);

0 commit comments

Comments
 (0)