Skip to content

Commit 0909aaf

Browse files
authored
Create script.js
For incident, adding a work note containing relevant CRs that can be attached to the incident.
1 parent ac2d8b0 commit 0909aaf

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

  • Server-Side Components/Business Rules/Add work notes for relevant Change Requests for Incident
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
// Add your code here
4+
if(current.cmdb_ci){
5+
var ci = current.cmdb_ci;
6+
7+
var chng = new GlideRecord('change_request');
8+
chng.addQuery('cmdb_ci', ci);
9+
chng.addQuery('state', '!=', '3');
10+
chng.addQuery('state', '!=', '4');
11+
chng.query();
12+
13+
var work_notes = 'Following change requests are associated with same CI. You can attach one of them.\n';
14+
15+
while(chng.next()){
16+
work_notes += chng.number + '\n';
17+
}
18+
19+
current.work_notes = work_notes;
20+
current.update();
21+
}
22+
23+
})(current, previous);

0 commit comments

Comments
 (0)