From 39c16c9dcdcb442cc2d4a351f7799f25cbbc9ca9 Mon Sep 17 00:00:00 2001 From: srikanthroyal932-cmyk Date: Thu, 30 Oct 2025 12:25:31 +0530 Subject: [PATCH 1/2] BRScript.js --- .../Script.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/Script.js diff --git a/Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/Script.js b/Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/Script.js new file mode 100644 index 0000000000..b71b50d6e1 --- /dev/null +++ b/Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/Script.js @@ -0,0 +1,15 @@ +(function executeRule(current, previous) { + if (previous.state != current.state && current.state == 'implement') { + var ciRel = new GlideRecord('task_ci'); + ciRel.addQuery('task', current.sys_id); + ciRel.query(); + while (ciRel.next()) { + var ci = new GlideRecord('cmdb_ci'); + if (ci.get(ciRel.ci_item)) { + ci.install_status = 4; // In Maintenance + ci.update(); + gs.info('CI ' + ci.name + ' moved to In Maintenance.'); + } + } + } +})(current, previous); From 218b4c69c3d8df48482558ab6a9aa4353e11caad Mon Sep 17 00:00:00 2001 From: srikanthroyal932-cmyk Date: Thu, 30 Oct 2025 12:30:00 +0530 Subject: [PATCH 2/2] README.md --- .../Set CI to In Maintenance on Change start/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/README.md diff --git a/Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/README.md b/Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/README.md new file mode 100644 index 0000000000..e5131bc92e --- /dev/null +++ b/Server-Side Components/Business Rules/Set CI to In Maintenance on Change start/README.md @@ -0,0 +1,9 @@ +Set CI to In Maintenance on Change start + +1. Write a Business Rule - After Update +2. Select the Change Request Table +3. Add a Condition that Change state = "Implement" +4. task_ci is the relationship table that links tasks to configuration items (ci_item) +5. Finds all relationship records where the task field equals this Change Request +6. Retrieve the CI whose sys_id is stored in ciRel.ci_item, It returns true if found. +7. Set the CI’s install_status to In Maintenance.