From 1cb941568ef11462d0789fcadc011a8651522ff3 Mon Sep 17 00:00:00 2001 From: SwapnaAbburi Date: Sun, 5 Oct 2025 00:48:23 -0400 Subject: [PATCH 1/3] Create Automatically approve when approvers are duplicated --- .../Automatically approve when approvers are duplicated | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Business Rules/Automatically approve when approvers are duplicated diff --git a/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated new file mode 100644 index 0000000000..a340cfcb97 --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated @@ -0,0 +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. From db5e92221765ee69514223ee51f111d9321b0884 Mon Sep 17 00:00:00 2001 From: SwapnaAbburi Date: Sun, 5 Oct 2025 02:01:11 -0400 Subject: [PATCH 2/3] Automatically approve when approvers are duplicated --- .../README.md | 13 +++++++++++++ .../auto-approve.js | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./README.md create mode 100644 Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./auto-approve.js diff --git a/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./README.md b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./README.md new file mode 100644 index 0000000000..0b93e41960 --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./README.md @@ -0,0 +1,13 @@ +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. + +###Usage Instructions + +Create a new Business Rule on the sysapproval_approver table. +Set the rule to run before insert or update. +Paste the script into the Script field. +Test in a sub-production environment to ensure expected behavior. + +###Notes + +This rule helps reduce redundant approvals and improves efficiency. +Ensure that business logic and compliance requirements allow auto-approvals before deploying. \ No newline at end of file diff --git a/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./auto-approve.js b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./auto-approve.js new file mode 100644 index 0000000000..350651618a --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated./auto-approve.js @@ -0,0 +1,14 @@ +(function executeRule(current, previous /*null when async*/ ) { + + var appr = new GlideRecord('sysapproval_approver'); + appr.addQuery('document_id', current.document_id);//look for approval requests for same task + appr.addQuery('approver', current.approver); //same approver exists? + appr.addQuery('state', 'approved'); + appr.addQuery('group','');//ensure this scenario not applied for group type approvals + appr.query(); + if (appr.next()) { + current.state = 'approved'; + current.comments = 'Auto-approved due to duplicate approver at multiple levels.'; + } + +})(current, previous); \ No newline at end of file From fecdea7540f600db1de71f682c363e62adb84dd1 Mon Sep 17 00:00:00 2001 From: SwapnaAbburi Date: Sun, 5 Oct 2025 02:03:40 -0400 Subject: [PATCH 3/3] Delete Server-Side Components/Business Rules/Automatically approve when approvers are duplicated --- .../Automatically approve when approvers are duplicated | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Server-Side Components/Business Rules/Automatically approve when approvers are duplicated diff --git a/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated b/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated deleted file mode 100644 index a340cfcb97..0000000000 --- a/Server-Side Components/Business Rules/Automatically approve when approvers are duplicated +++ /dev/null @@ -1 +0,0 @@ -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.