- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2025 12:11 PM
Hi @Atik
May you consider a simple business rule
Business Rule Setup:
Table: sc_req_item (RITM)
When: after update
Filter condition: state changes to Closed Complete (or any “closed” state you use)
Action: find all related sc_task records and close them.
Code:
(function executeRule(current, previous /*null when async*/) {
// Only run when RITM moves to closed state
if (current.state == 3 && previous.state != 3) { // 3 = Closed Complete
var task = new GlideRecord("sc_task");
task.addQuery("request_item", current.sys_id);
task.addQuery("active", true); // only open tasks
task.query();
while (task.next()) {
task.state = 3; // Closed Complete
task.active = false; // mark inactive
task.work_notes = "Auto-closed because parent RITM was closed (historical load)";
task.update();
}
}
})(current, previous);