Skip to content

Commit a4aba28

Browse files
authored
Feature/auto approve vip approvals (#1760)
* Create README.md * Update README.md part dos * Create script.js * added more details to the readme
1 parent 28e80fa commit a4aba28

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Description:
2+
This Business Rule will auto-approve an Approval [sysapproval_approver] record when the Approver and the Requested for on a RITM are the same, and the user is a VIP User. This allows VIP users to receive the services they requested faster and avoid an unecesary approval step in the process.
3+
4+
## Usage Instructions/Examples:
5+
This script is specfic for RITM's but could easily be refactored to work for other approvals on the platform (i.e. change requests).
6+
7+
#### When to run values:
8+
9+
- When: after
10+
- Note: This could run before, but I choose to make an update on another table (aka add a comment to the RITM about the auto-approval)
11+
- Note 2: If you choose to run this before, please remove the 'current.update()' from line 11 in the script
12+
- Insert: true
13+
- Update: false
14+
- Note: This could be updated to true if needed for your business process
15+
- Filter Conditions: Source table is sc_req_item AND State changes to Requested
16+
- Note: The source table can be changed to other tables such as change_request
17+
18+
## Prerequisites/Dependencies:
19+
1) A Catalog Item with approvals from VIP users
20+
2) A business process that allows VIP Users to bypass their own approvals
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
// Query the requested item to get the requested_for user
3+
var grReqItem = new GlideRecord('sc_req_item');
4+
grReqItem.get(current.sysapproval);
5+
var requestedFor = grReqItem.request.requested_for;
6+
7+
// Check if the approver is the same as the requested_for user AND a VIP User
8+
if (requestedFor == current.approver && current.approver.vip == true) {
9+
current.setValue('state', 'approved');
10+
current.update(); //Only needed because this is an after BR, remove this if you decide to do a before BR
11+
12+
grReqItem.comments = "This request was auto-approved due to Requester's VIP status.";
13+
grReqItem.update();
14+
}
15+
})(current, previous);

0 commit comments

Comments
 (0)