Skip to content

Commit cc6fd7f

Browse files
BRScript.js
1 parent 06c5594 commit cc6fd7f

File tree

1 file changed

+25
-0
lines changed
  • Server-Side Components/Business Rules/Auto-assign and notify owners of Affected CIs

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Business Rule: After Update on change_request
2+
// Condition: affected_ci field has changed
3+
(function executeRule(current, previous /*null for insert*/) {
4+
// Suppose affected CI list is in a related list table change_request_ci
5+
var ciRel = new GlideRecord('change_request_ci');
6+
ciRel.addQuery('change_request', current.sys_id);
7+
ciRel.query();
8+
9+
while (ciRel.next()) {
10+
var ci = ciRel.cmdb_ci.getRefRecord();
11+
if (ci.owner) {
12+
// create change_task (task table) record for owner
13+
var ct = new GlideRecord('change_task');
14+
ct.initialize();
15+
ct.change_request = current.sys_id;
16+
ct.cmdb_ci = ci.sys_id;
17+
ct.assigned_to = ci.owner;
18+
ct.short_description = 'Review Change for your CI: ' + ci.name;
19+
ct.insert();
20+
21+
// send notification – could simply use gs.eventQueue or similar
22+
gs.eventQueue('change.ci.owner.notification', ct, ci.owner, current.sys_id);
23+
}
24+
}
25+
})(current, previous);

0 commit comments

Comments
 (0)