Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Update CI status on Change Request Closure

1. Create a Business Rule - After Update
2. Select the Change Request Table.
3. Add a condition as when Change state = "Closed"
4. Run only when Change is moving to Closed
5. Query all CI relationships for this Change Request
6. Update CI status based on the condition
7. The relationship table that links a change (task) to CIs (ci_item).
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function executeRule(current, previous) {
// Run only when Change is moving to Closed
if (previous.state != current.state && current.state == 'closed') {

gs.info('Change ' + current.number + ' closed — updating related CI statuses.');

// Query all CI relationships for this Change
var ciRel = new GlideRecord('task_ci');
ciRel.addQuery('task', current.sys_id);
ciRel.query();

while (ciRel.next()) {
if (ciRel.ci_item) {
var ci = new GlideRecord('cmdb_ci');
if (ci.get(ciRel.ci_item)) {

// Example: Update CI status
ci.install_status = 1; // 1 = In Service (Active)
ci.update();

gs.info('CI ' + ci.name + ' status updated to In Service for Change ' + current.number);
}
}
}
}
})(current, previous);
Loading