diff --git a/Server-Side Components/Business Rules/Prevent closure if change tasks are open/Before_BR.js b/Server-Side Components/Business Rules/Prevent closure if change tasks are open/Before_BR.js new file mode 100644 index 0000000000..f6cf2a89ac --- /dev/null +++ b/Server-Side Components/Business Rules/Prevent closure if change tasks are open/Before_BR.js @@ -0,0 +1,14 @@ +function executeRule(current, previous /*null when async*/){ + if(current.close_code){ + var taskGR = new GlideRecord('change_task'); + taskGR.addQuery('change_request', current.sys_id); + taskGR.addQuery('state', '!=', '3') // Adjust as needed + taskGR.query(); + + if (taskGR.hasNext()){ + gs.addErrorMessage('You cannot close this change request until all change tasks are closed.'); + current.setAbortAction(true); // Prevent saving the form + } + } + +})(current, previous); diff --git a/Server-Side Components/Business Rules/Prevent closure if change tasks are open/README.md b/Server-Side Components/Business Rules/Prevent closure if change tasks are open/README.md new file mode 100644 index 0000000000..cd540ecba9 --- /dev/null +++ b/Server-Side Components/Business Rules/Prevent closure if change tasks are open/README.md @@ -0,0 +1,10 @@ +Prevent Closure if the change tasks are open + +1. Create a Before Business Rule. +2. Applicable to Change Request Table. +3. Use Before - Update Business Rule. +4. Add filter conditions if required. +5. Apply the Business Rule script. +6. If the change request have the active change tasks are still open then we can't proceed with the submission. +7. If required we can add few more query conditions. +8.