Skip to content

Commit caf2bd6

Browse files
authored
Business Rule: Add Work Notes for Related Change Requests by CI (#1707)
1 parent 242d9cb commit caf2bd6

File tree

2 files changed

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

2 files changed

+29
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Adds the Change Request numbers to the work notes of incidents that have the same CI.
2+
Operates on the Incident table as a Before Business Rule.
3+
4+
Excludes CRs that are closed and cancelled.
5+
Helps agents to quickly identify related changes during incident triage.
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)