Skip to content

Commit 2914895

Browse files
authored
Attachments check for High Risk/Impact change request before moving to Scheduled/Implement Phase (#2016)
* Create README.md * Create attachmentcheckonhighriskimpactChange.js * Update README.md * Update attachmentcheckonhighriskimpactChange.js
1 parent af88ba1 commit 2914895

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
This Before Update business rule acts as a safeguard in a Change management process,
2+
ensuring that critical changes(those marked as high impact or high risk)
3+
are properly documented before progressing to key implementation stages.
4+
5+
**BR Type**: 'Before', 'Update'
6+
**Table**: Change Request (change_request)
7+
**Condition**: 'State' 'changes to' 'Scheduled' OR 'State' 'changes to' 'Implement'
8+
9+
**What It Does**:
10+
-The BR triggers before a change request record is updated, specifically when the state changes to either Scheduled or Implement.
11+
12+
-It checks whether the change is classified as high impact or high risk.
13+
14+
-If the change meets either of those criteria, it verifies that at least two attachments are present on the record.
15+
These attachments are expected to be essential supporting documents like an Implementation Plan or Backout Procedure.
16+
17+
-If the required documentation is missing, the rule blocks the state change and displays an error message to the user,
18+
preventing the change from moving forward until compliance is met.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
var minAttachments = 2;
4+
5+
var isHighImpact = current.impact == '1';
6+
var isHighRisk = current.risk == '2';
7+
8+
if (isHighImpact || isHighRisk) {
9+
10+
var attachmentCount = 0;
11+
var attachment = new GlideAggregate('sys_attachment');
12+
attachment.addQuery('table_sys_id', current.sys_id);
13+
attachment.addAggregate('COUNT');
14+
attachment.query();
15+
if (attachment.next()) {
16+
attachmentCount = attachment.getAggregate('COUNT');
17+
}
18+
19+
if (attachmentCount < minAttachments) {
20+
21+
gs.addErrorMessage('State Change aborted: High-Impact/High-Risk Changes require at least ' + minAttachments + ' supporting documents (eg: Implementation Plan, Backout Procedure)' + 'attached before moving to the Scheduled/Implementation phase.');
22+
current.setAbortAction(true);
23+
}
24+
}
25+
26+
})(current, previous);

0 commit comments

Comments
 (0)