Skip to content

Commit db5e922

Browse files
authored
Automatically approve when approvers are duplicated
1 parent 1cb9415 commit db5e922

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
In certain scenarios, the same approver might appear multiple times in the approval flow for a Change or Request. This code snippet ensures that if an approver has already approved the request once, any subsequent approval requests assigned to them are automatically marked as approved.
2+
3+
###Usage Instructions
4+
5+
Create a new Business Rule on the sysapproval_approver table.
6+
Set the rule to run before insert or update.
7+
Paste the script into the Script field.
8+
Test in a sub-production environment to ensure expected behavior.
9+
10+
###Notes
11+
12+
This rule helps reduce redundant approvals and improves efficiency.
13+
Ensure that business logic and compliance requirements allow auto-approvals before deploying.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
var appr = new GlideRecord('sysapproval_approver');
4+
appr.addQuery('document_id', current.document_id);//look for approval requests for same task
5+
appr.addQuery('approver', current.approver); //same approver exists?
6+
appr.addQuery('state', 'approved');
7+
appr.addQuery('group','');//ensure this scenario not applied for group type approvals
8+
appr.query();
9+
if (appr.next()) {
10+
current.state = 'approved';
11+
current.comments = 'Auto-approved due to duplicate approver at multiple levels.';
12+
}
13+
14+
})(current, previous);

0 commit comments

Comments
 (0)