Skip to content

Commit 118c3e3

Browse files
authored
Create attachmentcheckonhighriskimpactChange.js
1 parent f057899 commit 118c3e3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 attachment = new GlideRecord('sys_attachment');
11+
attachment.addQuery('table_sys_id', current.sys_id);
12+
attachment.query();
13+
14+
var attachmentCount = attachment.getRowCount();
15+
16+
if (attachmentCount < minAttachments) {
17+
18+
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.');
19+
current.setAbortAction(true);
20+
}
21+
}
22+
23+
})(current, previous);

0 commit comments

Comments
 (0)