File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Server-Side Components/Business Rules/Update CI status on Change Request closure Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ Update CI status on Change Request Closure
2+
3+ 1. Create a Business Rule - After Update
4+ 2. Select the Change Request Table.
5+ 3. Add a condition as when Change state = "Closed"
6+ 4. Run only when Change is moving to Closed
7+ 5. Query all CI relationships for this Change Request
8+ 6. Update CI status based on the condition
9+ 7. The relationship table that links a change (task) to CIs (ci_item).
Original file line number Diff line number Diff line change 1+ (function executeRule(current, previous) {
2+ // Run only when Change is moving to Closed
3+ if (previous.state != current.state && current.state == 'closed') {
4+
5+ gs.info('Change ' + current.number + ' closed — updating related CI statuses.');
6+
7+ // Query all CI relationships for this Change
8+ var ciRel = new GlideRecord('task_ci');
9+ ciRel.addQuery('task', current.sys_id);
10+ ciRel.query();
11+
12+ while (ciRel.next()) {
13+ if (ciRel.ci_item) {
14+ var ci = new GlideRecord('cmdb_ci');
15+ if (ci.get(ciRel.ci_item)) {
16+
17+ // Example: Update CI status
18+ ci.install_status = 1; // 1 = In Service (Active)
19+ ci.update();
20+
21+ gs.info('CI ' + ci.name + ' status updated to In Service for Change ' + current.number);
22+ }
23+ }
24+ }
25+ }
26+ })(current, previous);
You can’t perform that action at this time.
0 commit comments