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. 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);