Skip to content

Commit af91a7b

Browse files
authored
Create script.js
This Business Rule checks for Change Requests linked to the same Configuration Item (CI) whenever an Incident is created or updated. If any active CRs are found (excluding Closed and Canceled), their numbers are added to the Incident’s work notes. This helps agents identify related changes quickly and avoid duplicate effort.
1 parent ac2d8b0 commit af91a7b

File tree

1 file changed

+24
-0
lines changed
  • Server-Side Components/Business Rules/Add work notes for relevant Change Requests for Incident

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
if(current.cmdb_ci){
4+
var ci = current.cmdb_ci.getValue();
5+
6+
var chng = new GlideRecord('change_request');
7+
chng.addQuery('cmdb_ci', ci);
8+
chng.addQuery('state', '!=', '3');
9+
chng.addQuery('state', '!=', '4');
10+
chng.query();
11+
12+
var work_notes = '';
13+
14+
while(chng.next()){
15+
work_notes += chng.getValue('number') + '\n';
16+
}
17+
18+
if(work_notes){
19+
current.work_notes = 'Following change requests are associated with the same CI. You can attach one of them.\n' + work_notes;
20+
}
21+
22+
}
23+
24+
})(current, previous);

0 commit comments

Comments
 (0)